Accessible Tables: Headers, Captions and Scope
Also called: Accessible data tables, Table headers, Screen reader friendly tables
Definition
Accessible tables are data tables marked up so that their structure is available to software: real table elements, header cells (th) linked to their data cells with scope or headers and id, and a caption. This is how they meet WCAG 1.3.1 Info and Relationships at Level A.
Accessible tables let screen reader users understand data the way sighted users do: by knowing which row and column a value belongs to. When a price list is built from styled div elements or the headers are just bold cells, a screen reader reads "49, 99, 149" with no idea which plan or which month each number means. With real header cells, it says "Pro, yearly, 99".
What it means
Tables fall under WCAG 1.3.1 Info and Relationships (Level A, WCAG 2.2): information, structure and relationships conveyed through presentation must be programmatically determined or available in text. A grid of rows and columns is exactly such a relationship – see info and relationships for the full criterion.
W3C lists these techniques for data tables:
| Technique | What it does | When to use it |
|---|---|---|
| H51 | Table markup (table, tr, th, td) for tabular information |
Every data table |
| H63 | scope on header cells (col, row, colgroup, rowgroup) |
Simple tables with one header row and/or column |
| H43 | id on headers, headers on data cells |
Complex tables with several header levels |
| H39 | caption names the table |
Any table that needs a title |
And the failures to avoid: F91 (table headers not correctly marked up), F90 (headers and data cells associated wrongly through headers and id) and F46 (using th, caption or a non-empty summary in layout tables).
Examples
<table>
<caption>Plans and prices per month</caption>
<thead>
<tr>
<th scope="col">Plan</th>
<th scope="col">Monthly</th>
<th scope="col">Yearly</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Starter</th>
<td>€19</td>
<td>€190</td>
</tr>
<tr>
<th scope="row">Pro</th>
<td>€49</td>
<td>€490</td>
</tr>
</tbody>
</table>The caption names the table, column headers carry scope="col", and the first cell of each row is a row header with scope="row". A screen reader moving to "€490" announces "Pro, Yearly". On narrow screens, let the table scroll horizontally inside its container instead of breaking it apart – that keeps the structure and helps with reflow.
Use table only for data, mark headers with th and scope, add a caption, keep one value per cell, and use headers and id when headers span several levels.
Build data grids from div elements, fake headers with bold td cells, leave header cells empty, merge cells for decoration, or use tables for page layout with th and caption inside.
How to check accessible tables
Questions
What makes a table accessible?
Real table markup, header cells (th) linked to their data cells with scope or with headers and id, and a caption that names the table. Then screen readers can tell users which row and column each value belongs to.
When should I use scope and when headers?
scope is enough for simple tables with one header row and/or one header column. Use headers and id for complex tables where a data cell belongs to more than one level of headers.
Do tables need a caption?
A caption is the W3C technique (H39) for naming a data table, and it helps screen reader users decide whether to read the table. A visible heading right before the table also gives context, but only the caption is tied to it in the code.
Can I use tables for layout?
Use CSS for layout. If a layout table is unavoidable, it must not contain th, caption or a non-empty summary – W3C lists that as failure F46 – and it should carry role="presentation".
Is WCAG 1.3.1 required by the European Accessibility Act?
Yes, indirectly. The European Accessibility Act points to EN 301 549, which takes over WCAG Level AA for the web. 1.3.1 is Level A and therefore included.
Related terms
Info and Relationships: Structure in the Code
Info and Relationships is WCAG success criterion 1.3.1: information, structure and relationships conveyed through presentation can be programmatically determined or are available in text.
Read definition: Info and Relationships: Structure in the CodeScreen Reader: How It Reads Websites and What It Needs
A screen reader is assistive software that reads the content and controls of a screen aloud or outputs them on a braille display. It relies on the names, roles and states that a website exposes through the browser's accessibility tree.
Read definition: Screen Reader: How It Reads Websites and What It NeedsMeaningful Sequence: Correct Reading Order
Meaningful Sequence is WCAG success criterion 1.3.2: when the sequence in which content is presented affects its meaning, a correct reading sequence can be programmatically determined.
Read definition: Meaningful Sequence: Correct Reading OrderReflow: Content That Fits at 400% Zoom
Reflow is WCAG success criterion 1.4.10. Content must work without loss of information or functionality and without scrolling in two directions at a width equal to 320 CSS pixels – or a height of 256 CSS pixels for horizontally scrolling content.
Read definition: Reflow: Content That Fits at 400% Zoom