Tables

Tables in HTML are a great way for displaying data that can be looked up using the row and columns.

Historically, tables have been used historically for maintaining the layout of HTML pages. Using tables for layout is now conidered bad practice, and causes issues with the accessibility of websites.

Tables should only ever be used where we want to display data that can be looked up by row and column, as in the example below

The key elements used to construct a table are as follows:

Example Table

<table>
<thead>
<tr><th>Name</th><th>Phone</th><th>Office</th></tr>
</thead>
<tbody>
<tr><td>Andrew</td><td>3098</td><td>TAS033</td></tr>
<tr><td>Adam</td><td>1668</td><td>CML010</td></tr>
<tr><td>Matt</td><td>1296</td><td>CML007</td></tr>
</tbody>
</table>

This will render in a similar way to that shown below, though by default the browser may add some grid lines:

NamePhoneOffice
Andrew3098TAS033
Adam1668CML010
Matt1296CML007

You may wish to write <td> elements on a new line to make reading your code easier, this is fine, as the web browser will ignore the extra lines.