We can create a table in HTML/XHTML by using <table> tag. Inside <table> element the table is written out row by row. A row is contained inside a <tr> tag . which stands for table row. And each cell is then written inside the row element using a <td> tag, which stands for table data.
Example:
<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>
This will produce following result:
NOTE: In the above example border is an attribute of <table> and it will put border across all the cells. If you do not need a border then you cal use border="0".
Table Heading
Table heading can be defined using <th> element. This tag will be put to replace <td> tag which is used to represent actual data. Normally you will put your top row as table heading as shown below, otherwise you can use <th> element at any place:
<table border="1">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>David</td>
<td>5000</td>
</tr>
<tr>
<td>Catherene</td>
<td>7000</td>
</tr>
</table>
This will produce following result. You can see its making heading as a bold one:
Example:
<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>
This will produce following result:
| Row 1, Column 1 | Row 1, Column 2 | |
| Row 2, Column 1 | Row 2, Column 2 |
Table Heading
Table heading can be defined using <th> element. This tag will be put to replace <td> tag which is used to represent actual data. Normally you will put your top row as table heading as shown below, otherwise you can use <th> element at any place:
<table border="1">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>David</td>
<td>5000</td>
</tr>
<tr>
<td>Catherene</td>
<td>7000</td>
</tr>
</table>
This will produce following result. You can see its making heading as a bold one:
| Name | Salary | |
| David | 5000 | |
| Catherene | 7000 |
No comments:
Post a Comment