Rule

Table header associations

Data tables must have properly associated header cells.

Rule
table-headers
WCAG 2.2
1.3.1 Info and Relationships (opens in a new tab) (Level A)
Severity
Serious

What it checks

A data table needs header cells, so a screen reader can say which row and column each value belongs to. The rule looks at tables of at least two rows and two columns with at least four cells of text. It fails one with no <th>, no cell with role="columnheader" or role="rowheader", and no scope or headers attribute.

It also fails a table where a headers attribute lists an id that is not a header cell of the same table. Tables with role="presentation" or role="none", and smaller tables, are not checked.

When a person decides

A table without headers is sent for review instead when it looks like layout: when it sits inside another table or holds one, when its cells contain headings, paragraphs, lists or forms, or when every cell holds only a link or button. A person needs to say whether it presents data.

Example

Fails

<table>
  <tr><td>Plan</td><td>Storage</td><td>Price</td></tr>
  <tr><td>Basic</td><td>10 GB</td><td>£2</td></tr>
  <tr><td>Plus</td><td>100 GB</td><td>£5</td></tr>
</table>

Passes

<table>
  <tr><th scope="col">Plan</th><th scope="col">Storage</th><th scope="col">Price</th></tr>
  <tr><td>Basic</td><td>10 GB</td><td>£2</td></tr>
  <tr><td>Plus</td><td>100 GB</td><td>£5</td></tr>
</table>

The engine is tested against both examples.

How to fix it

Mark header cells with <th>, adding scope="col" or scope="row" when a table has both. If the table only arranges content, add role="presentation".

Check your own pages

This rule runs in every pour audit: the browser extension, the bookmarklet, the command line and the editor. Get pour, free.