The table tag
The table tag creates a table. It is used together with the tr, td, th tags.
The tr tag creates a table row, and the td and th tags create cells in that table. The difference between td and th is that the former is a regular cell, while the latter is a header cell.
Attributes
| Attribute | Description |
|---|---|
cellspacing |
Specifies the distance between cells.
Deprecated, use CSS property border-spacing instead.
|
cellpadding |
Specifies the distance between the text and the cell border.
Deprecated, use CSS property padding instead.
|
border |
Specifies the border of cells and tables.
Deprecated, use CSS property border instead.
|
Example
Let's create a table with cells th and td:
<table>
<tr>
<th>Name</th>
<th>Surn</th>
<th>Salary</th>
</tr>
<tr>
<td>name1</td>
<td>surn1</td>
<td>200$</td>
</tr>
<tr>
<td>name2</td>
<td>surn2</td>
<td>1000$</td>
</tr>
</table>
table, td, th {
border: 1px solid black;
}
: