All cells in a <table> element that use the headers attribute must only refer to other cells of that same <table>

Rule ID: td-headers-attr
Ruleset: axe-core 3.0
User Impact: Serious
WCAG: 1.3.1

Accessibility Testing Designed for Developers - No Training Required

Join Deque's exclusive beta testing community and help us reach our goal of accessibility as standard part of every sprint by 2022.

Compliance Data & Impact

User Impact

Disabilities Affected

  • Blind
  • Deafblind

Requirement(s)

  • WCAG 2.1 (A): MUST
  • WCAG 2.0 (A): MUST
  • Section 508: MUST

WCAG Success Criteria

  • 1.3.1 Info and Relationships

Section 508 Guidelines

  • 1194.22 (g) Row and column headers for data tables

How to Fix the Problem

To fix the problem, ensure that each cell in a table using headers refers to another cell in the same table by creating a scope attribute value on each <th> element within <tr&;gt; elements. This rule checks that references to header columns and rows connected to specific <td> elements.

The scope attribute tells the browser and screen reader that everything under the column is related to the header at the top, and everything to the right of the row header is related to that header.

Applying the scope attribute to our table the markup now looks like this:

Example

<table>
  <caption><strong>Greensprings Running Club Personal Bests</strong></caption>
  <thead>
    <tr>
      <th scope="col">Name</th>
      <th scope="col">1 mile</th>
      <th scope="col">5 km</th>
      <th scope="col">10 km</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <th scope="row">Mary</th>
      <td>8:32</td>
      <td>28:04</td>
      <td>1:01:16</td>
    </tr>

    <tr>
      <th scope="row">Betsy</th>
      <td>7:43</td>
      <td>26:47</td>
      <td>55:38</td>
    </tr>

    <tr>
      <th scope="row">Matt</th>
      <td>7:55</td>
      <td>27:29</td>
      <td>57:04</td>
    </tr>

    <tr>
      <th scope="row">Todd</th>
      <td>7:01</td>
      <td>24:21</td>
      <td>50:35</td>
    </tr>
  </tbody>

</table>

Note that the top headers for Name, 1 mile, 5 km and 10 km are all marked up with th elements, as are the row headers for Mary, Betsy, Matt and Todd. Each of these header cell have also been given the scope attribute values of col or row depending on whether they are column or row header cells.

There are two more methods for associating header cells with data cells: colgroup/rowgroup for headers spanning multiple columns or rows, and the id + headers method for more complex tables.

Why it Matters

Screen readers have a specific way of announcing tables. When tables are not properly marked up, this creates the opportunity for confusing or inaccurate screen reader output.

Sighted users can usually tell at a glance what the table's headers are and what their relationship to the data is. For non-sighted users this must be done in the markup.

When a data table is designed with accessibility in mind, the user enters into table navigation mode, which allows the user to navigate from cell to cell within the table while hearing the screen reader announce the corresponding table headers for the data cells. Hearing the table headers is especially helpful when navigating through large data tables, or when cells contain similar-sounding data that could be easily confused.

Table navigation mode is not useful, though, if the table lacks accessibility features.

Rule Description

Data table markup can be tedious and confusing. Markup tables semantically and with the correct header structure. Screen readers have features to ease table navigation, but tables must be marked up accurately for these features to work correctly.

The Algorithm (in simple terms)

Checks that data tables are marked up semantically and have the correct header structure.

Resources

Refer to the complete list of axe 3.0 rules.

Was this information helpful?

You have already given your feedback, thank you..

Your response was as follows:

Was this information helpful?
Date/Time feedback was submitted: