Tables

Some information is a grid. A train timetable, a pricing plan, a league table, a set of nutrition facts: each one has rows and columns, and the meaning lives in how they line up. HTML has a dedicated set of elements for exactly this kind of content, and using them keeps the grid readable both on screen and to software that reads the page aloud.
Table basics
A table is a grid of rows and columns, the same shape as a spreadsheet. You build one from four elements. <table> wraps the whole grid. Each <tr> is one row (tr is short for table row). Inside a row, each <td> is one cell of data (td is table data). When a cell labels its column or row, you use <th> instead (th is table header), and the browser shows it bold and centred so it stands apart from the data.
<table>
<tr>
<th>Day</th>
<th>Opening hours</th>
</tr>
<tr>
<td>Monday</td>
<td>8:00 to 18:00</td>
</tr>
<tr>
<td>Saturday</td>
<td>9:00 to 14:00</td>
</tr>
</table>Two heading cells across the top, then two data rows. The browser draws the grid, sizes each column to fit its content, and renders the two <th> cells bold.
<table> around the whole thing, <tr> for each row, <td> for a cell, and <th> for a heading cell. The heading cells come out bold and centred so they stand apart from the data. Build it one row at a time and the columns line themselves up. Structuring a table
The order of your rows is the order people read them, so put the heading row, the one built from <th> cells, at the top. Then keep every row the same length: if the heading row has three cells, every <tr> below it needs three <td> cells too. A row with a missing cell leaves a gap in the grid and the columns stop lining up. There is nothing new to learn here, only care with the rows you already know.
<table>
<caption>Quarterly revenue by region</caption>
<thead>
<tr>
<th>Region</th>
<th>Q1</th>
<th>Q2</th>
</tr>
</thead>
<tbody>
<tr>
<th>North</th>
<td>£12,000</td>
<td>£15,400</td>
</tr>
<tr>
<th>South</th>
<td>£9,800</td>
<td>£11,200</td>
</tr>
</tbody>
<tfoot>
<tr>
<th>Total</th>
<td>£21,800</td>
<td>£26,600</td>
</tr>
</tfoot>
</table><th> cells. Then keep every row the same length: three headings up top means three <td> cells in each row below. A missing cell is a gap in the grid, and that is the thing that trips people up early. Accessible tables
An accessible table is one that makes sense to everyone, including people who listen to the page with a screen reader (software that reads the page aloud) instead of seeing it. The most useful thing you can do is already in your toolkit: use <th> for every heading cell, not <td>. A screen reader can then tell its listener which cells are labels and which are data, so a value like "£15" is announced together with the column it belongs to. A table where every cell is a plain <td> reads as a flat wall of numbers with nothing to anchor them.
Accessibility runs wider than tables alone; the Accessibility chapter covers the rest of the picture.
<th> for headings and <td> for data. A screen reader leans on that split to read each value with the heading it belongs to, so £15 arrives with its column instead of on its own. Skip it and the whole table lands as a wall of loose numbers. Tables are for data, not layout
There was a time, before CSS could handle layout, when people built whole page layouts out of tables: a <table> to put the menu on the left and the content on the right. It works visually, so you still see it in old pages and some email templates. Do not copy it. A table is for tabular data, information that belongs in a grid of rows and columns. Arranging the pieces of a page is CSS's job. Using a table to position things instead of to hold data makes the page harder to read for anyone using a screen reader, and harder to adjust later.
<!-- Wrong: a table used to place a sidebar next to an article -->
<table>
<tr>
<td><nav>...</nav></td>
<td><article>...</article></td>
</tr>
</table>
<!-- Right: real elements, with CSS handling the columns -->
<nav>...</nav>
<article>...</article>This is the same separation of structure and presentation set out in What is HTML: structure in HTML, layout in CSS. For choosing elements by their meaning, see Semantic HTML.

