HTML tables allow you to display data in rows and columns.
| Tag | Meaning |
|---|---|
<table> |
Creates a table |
<tr> |
Table row |
<td> |
Table data/cell |
<th> |
Table header cell |
<table border="1">
<tr>
<td>Row 1, Cell 1</td>
<td>Row 1, Cell 2</td>
</tr>
<tr>
<td>Row 2, Cell 1</td>
<td>Row 2, Cell 2</td>
</tr>
</table>
Tables can include borders, spacing, padding, and alignment.
| Attribute | Description |
|---|---|
border |
Adds a border to the table |
cellpadding |
Space inside each cell |
cellspacing |
Space between cells |
width |
Width of table |
align |
Aligns table (deprecated but works) |
<table border="1" cellpadding="10" cellspacing="5" width="50%">
<tr>
<td>A</td>
<td>B</td>
</tr>
</table>