Lesson 26 of 51 · Module 4, lesson 5 of 6 · 3 min
Table headers and captions
Mark table headers so that screen readers can announce which row and column each value belongs to.
What you'll learn
- How to mark column and row headers with
scope- How to group rows with
<thead>,<tbody>and<tfoot>- How a screen reader reads a table
Why this matters
A sighted reader glances up and sideways to see which column and row a number belongs to. A screen reader user cannot glance — the screen reader has to announce the headers. It can only do that if your HTML says clearly which cells are headers and what they describe.
Column and row headers: scope
The scope attribute on <th> says what the header describes:
scope="col"— the header of a column.scope="row"— the header of a row.
In the study plan, "Day", "Topic" and "Minutes" are column headers. The day names are row headers: each one describes its whole row.
Groups of rows
<thead>holds the header row(s).<tbody>holds the data rows.<tfoot>holds summary rows, such as a total.
The complete, accessible table
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Study plan</title>
</head>
<body>
<table>
<caption>Study time this week</caption>
<thead>
<tr>
<th scope="col">Day</th>
<th scope="col">Topic</th>
<th scope="col">Minutes</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row">Monday</th>
<td>Headings</td>
<td>30</td>
</tr>
<tr>
<th scope="row">Wednesday</th>
<td>Links</td>
<td>45</td>
</tr>
<tr>
<th scope="row">Friday</th>
<td>Images</td>
<td>40</td>
</tr>
</tbody>
<tfoot>
<tr>
<th scope="row">Total</th>
<td></td>
<td>115</td>
</tr>
</tfoot>
</table>
</body>
</html>
What you'll see: the same table as before, now with the day names in bold (they are headers) and a "Total" row at the bottom.
What the screen reader does
When a screen reader user moves to the cell "45", they hear something like "Wednesday, Minutes, 45" — the row header, the column header and the value. Without <th> and scope, they would hear only "45".
Try it yourself
- Select the example and choose Try it.
- Add a row for Sunday, with its day as a row header, and update the total.
- Open the page in your browser, open the developer tools, and in Chrome or Edge choose the Accessibility pane in the Elements panel. Click a cell: you can see how the browser describes it.
Common mistakes
- Using
<td>with bold text as a header. It looks like a header, but a screen reader does not know. Fix: use<th>. - No
scopeon headers. Simple tables often work anyway, but not always. Fix: addscope="col"orscope="row"every time. - A caption written as a paragraph above the table. It is not connected to the table. Fix: use
<caption>. <tfoot>for normal data rows. Fix: use it only for totals or summaries.
Check yourself
- Which attribute tells a screen reader whether a header describes a column or a row?
- In a list of days and topics, what
scopeshould the day names have? - Which element holds a row with a total?
Answers
scope.scope="row"— each day describes its row.<tfoot>.
Next: sometimes one cell covers two columns or two rows — like a two-hour lesson in a timetable.


