Skip to content

table-header-missing-scope

Added in 0.2.12 · Related issues · View source

What it does

Checks that every <th> header cell has a scope attribute set to one of the valid keywords row, col, rowgroup, or colgroup.

Why is this bad?

The scope attribute tells assistive technology whether a header cell labels a column or a row. Without it, screen readers must guess the header-to-data association in anything but the simplest table, so cells may be announced with the wrong header or none at all.

Example

<table>
    <tr><th>Name</th><th scope="column">Email</th></tr>
    <tr><td>Ada</td><td>ada@example.com</td></tr>
</table>

Use instead:

<table>
    <tr><th scope="col">Name</th><th scope="col">Email</th></tr>
    <tr><td>Ada</td><td>ada@example.com</td></tr>
</table>

References