If we want to print data in the form of table in html we use TABLE tag. Table contain rows and columns.
- For creating rows in table we use
tr tag with in table tag.
- For creating columns in table we use
td tag with in tr tag.
Syntax
<table>
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
OUTPUT
Row 1, Column 1 Row 1, Column 2
Row 2, Column 1 Row 2, Column 2
For adding border in this table we use border attribute it will put a border in all the cells. If we do not want a border then we can use border="0".
eg:-
<table border="1">
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
OUTPUT
HTML Tables
Row 1, Column 1 |
Row 1, Column 2 |
Row 2, Column 1 |
Row 2, Column 2 |
TABLE HEADING
For giving table columns a heading we use th tag.
eg:-
<table border="1">
<tr>
<th>Name</th>
<th>ADRESS</th>
</tr>
<tr>
<td>suresh</td>
<td>delhi</td>
</tr>
<tr>
<td>pankaj</td>
<td>lucknow</td>
</tr>
OUTPUT
HTML Table Header
Name |
ADDRESS |
Suresh |
Delhi |
Pankaj |
Lucknow |
0 Comment(s)