To make an HTML table accessible, mark every header cell with <th>, add a scope attribute so assistive technology knows whether it labels a column or a row, and give the table a <caption>. With that markup a screen reader can announce the right headings before each data cell. This is the core of an accessible html table scope setup.
Sighted users scan a table visually. Screen reader users move cell by cell, and they depend on the markup to hear which column and row a value belongs to. Without proper headers they hear only a stream of numbers.
A header must be a <th> element. A <td> made bold with CSS looks like a header but is announced as plain data.
When the user lands on the cell with 91, a screen reader can say something like "Science, Asha, 91", because the column header and the row header are both marked.
The scope attribute is valid on <th> only. It tells assistive technology which cells the header describes.
| Value | The header applies to |
|---|---|
col | The cells below it in the same column |
row | The cells to its right in the same row |
colgroup | A group of columns, used with colspan |
rowgroup | A group of rows, such as a <tbody> |
auto | Browser decides; this is the default |
For a simple table with one header row and one header column, scope="col" and scope="row" are enough. Modern browsers often work out the direction on their own for simple tables, but writing scope removes the guesswork and helps older assistive tools.
A <caption> is the accessible name of the table. Users who list the tables on a page hear the caption, so make it specific, for example "Exam results by student" and not "Table 1". If you need longer guidance, add a paragraph and link it with aria-describedby.
When a heading spans several columns, give it scope="colgroup" and the sub-headings scope="col".
The empty corner cell is a <td>, not a <th>, because it labels nothing.
If a table has headers that do not fit a simple grid, each <td> can list the ids of its header cells.
Support is decent in current screen readers, but this style is hard to maintain. Splitting one complex table into two simple tables is usually the better fix.
<th> cells; use a <td> for an empty corner.role="presentation" to a data table, because that removes the table meaning.Markup is not the only part. Keep text contrast at the WCAG 2.2 AA level (4.5:1 for normal text), do not use colour alone to show meaning, and keep row lines or alternate shading so the eye can follow a row. A table that is wider than the screen should scroll inside a wrapper with a focusable region, which the responsive table article covers.
It is not required for simple tables because browsers infer it, but it is recommended and makes the table dependable. It is needed for colgroup and rowgroup cases.
No. In current HTML scope is valid only on <th>. The old use on <td> is obsolete.
A <caption> is visible and is the native name. aria-label is hidden and only useful when a visible title is not wanted. Prefer the caption.
Not on a native <table>. The role is already built in, so repeating it adds nothing.
An accessible table uses <th> for every header, scope to show direction, <caption> to name the table and <thead> and <tbody> for structure. Keep tables simple, avoid layout tables, check colour contrast and test with a real screen reader.