Checkpoint (G) states that row and column headers shall be identified for data tables. See the sections below for specific examples and techniques.
HTML tables can be used for page layout and for displaying rows and columns of related data in "data tables". Data tables use row and/or column headers to associate cells of information with other data. Since they associate cells with other cells in the table, they require additional markup to make sense to users of assistive technology. Unlike data tables, layout tables require no additional tags to be accessible.
In data tables there are two main ways of relating headers to data: scope and headers/ids. There are also other means that are generally more complex, involving <thead>, <tbody>, <rowgroup> and <colgroup> tags in conjunction with headers/id. Try to structure your tables to use the less complex methods whenever possible.
Using "Scope" Attributes
This is by far the easiest way to associate header (<th>) cells and data cells. For column header <th> cells, simply include scope="col" in the <th> tag. For row header <th> cells, use scope = "row".
Here is a very simple table that uses scope="col" to associate column headers to data cells.
|Homework Due Dates||Quiz Dates||Test Dates|
<th scope="col">Homework Due Dates</th>
<th scope="col">Quiz Dates</th>
<th scope="col">Test Dates</th> </tr>
<td>10/18/02</td> </tr> </table>
Suppose we wanted to display students' scores. To do this we would add row headers on the left of the table.
|Homework 1||Quiz 1||Test 1|
In this example, "87%" is Bob's score for the first homework assignment – it is associated with the "Bob" row header and "Homework 1" column header. To make this table compliant add a blank cell (upper left) and row headers with scope="row."
<table width="440"> <tr> <td></td>
<th scope="col">Homework 1</th>
<th scope="col">Quiz 1</th>
<th scope="col">Test 1</th> </tr> <tr> <th scope="row">Bob</th>
<td>80%</td> </tr> <tr> <th scope="row">Scott</th>
<td>94%</td> </tr> <tr> <th scope="row">Tara</th>
<td>91%</td> </tr> </table>
Checkpoint (G) Techniques
See the Checkpoint (G) techniques for instructions for this section.
For more information about designing complex tables that are accessible, refer to Checkpoint (H).