Dostępność
a11y/table-headers
Data tables mark their header cells with th (with scope when needed); layout tables carry role="presentation".
poważnastatyczneWCAG 1.3.1 · Afe-a11y-tables
Dlaczego
Screen readers read a cell together with its column and row headers ("Price, Basic: Free"). With bold <td> cells instead of <th>, a table of numbers becomes a list of values with no meaning.
Poprawka
Use <th scope="col"> for column headers (in <thead>) and <th scope="row"> for the first cell of each row when it names the row. Add a <caption>. For tables used only to lay out an email or a legacy page, set role="presentation".
Przykłady
<!-- bad -->
<table><tr><td><b>Plan</b></td><td><b>Price</b></td></tr><tr><td>Basic</td><td>Free</td></tr></table>
<!-- good -->
<table>
<caption>Plans</caption>
<thead><tr><th scope="col">Plan</th><th scope="col">Price</th></tr></thead>
<tbody><tr><th scope="row">Basic</th><td>Free</td></tr></tbody>
</table>Źródła
Fakty
- Identyfikator
a11y/table-headers- Waga
- poważna
- Sprawdzanie
- statyczne sprawdzane w kodzie źródłowym przez
audit - Dotyczy plików
htmlangularvuesvelteastrojsx- WCAG 2.2
- 1.3.1, poziom A
- Ten sam problem w
- axe-core
td-has-header, axe-coreth-has-data-cells - Uczy jej skill
fe-a11y-tablesData tables- Od wersji
- 0.1.0
Przeczytaj w terminalu
npx github:dawidolko/frontend-skills explain a11y/table-headers