Definition of a table structure starts with <table> tag, which requires a closing one (</table>). The "border" attribute of this tag specifies the width of the table border in pixels.
The table consists of rows, which are defined by using the <tr> and </tr> tags.
Each row consists of cells, which are defined by using the <td> and </td> tags. Another possibility to define a table cell is to use the <th> and </th> tags. The difference between these tags is the in the second case the cell contents will be automatically centered and put in a bold font.
The table might have a caption created as follows:
The caption will by default be put above the table and centered.
Putting all together, consider the following example:
Layout | HTML tags | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
| <table> <caption>Table 1</caption> <tr> <th>Col1</th> <th>Col2</th> <th>Col3</th> </tr> <tr> <td>First cell</td> <td>Second cell</td> <td>Third cell</td> </tr> <tr> <td>Forth cell</td> <td>Fifth cell</td> <td>Sixth cell</td> </tr> </table> |
The border attribute controls the width of the table border:
where the value is the width of the border in pixels. The default width is 1 pixel.
border="0" | border="5" | border="10" | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
|