Tables
Tables are used for displaying tabular data, as you would in a word processor or spreadsheet. In the past tables have been heavily misused to lay out elements in a document - this is strongly discouraged.
In its basic form, a table consists of a set of rows (TR
elements), which in turn hold table cells (TD
elements).
The THEAD
element should be used to enclose your header rows, allowing you to style them differently.
<table>
<thead>
<tr>
<td>Name</td>
<td>Age</td>
<td>Eye colour</td>
</tr>
</thead>
<tr>
<td>Alice</td>
<td>31</td>
<td>Blue</td>
</tr>
<tr>
<td>Tony</td>
<td>20</td>
<td>Brown</td>
</tr>
<tr>
<td>Mary</td>
<td>24</td>
<td>Green</td>
</tr>
</table>
Name | Age | Eye colour |
Alice | 31 | Blue |
Tony | 20 | Brown |
Mary | 24 | Green |
Useful CSS properties to control the rendering of a table include: border, text-align and vertical-align
They can apply to the TABLE
, THEAD
, TR
and TD
elements.
Reference
- TABLE element (W3C)
- TABLE element (MDN)