Proper Use of Table Captions
Rule ID: table-fake-caption
Ruleset: axe-core 4.10
User Impact: Serious
Guidelines: WCAG 2.1 (Experimental), WCAG 2.0 (Experimental), Section 508, EN 301 549
How to Fix the Problem
To ensure full accessibility, do not simulate table captions using a cell with a colspan
attribute. Instead, use the <caption>
element, which is the correct semantic method for labeling tables.
Correct Approach
Use the <caption>
element directly inside the <table>
tag to define a table’s title or purpose. Here’s how:
What to Avoid
Avoid using a table row with a single <td>
or <th>
that spans multiple columns using colspan
to visually mimic a caption. For example:
This may look like a caption visually but does not expose the information programmatically to screen readers.
Why it Matters
Screen reader users depend on properly structured table markup to navigate and understand tabular data. The <caption>
element is specifically recognized by assistive technologies to announce the purpose or summary of a table.
If a table uses a colspan
to simulate a caption, screen readers will not recognize or announce it as such. This can lead to confusion and makes it more difficult for users with disabilities to understand what the table is for.
Accessible captions:
-
Help screen reader users locate and distinguish between multiple tables.
-
Provide important context before reading table headers and data.
-
Improve usability and compliance with accessibility standards.
Rule Description
This rule checks for misuse of colspan
cells in place of the actual <caption>
element. The goal is to ensure that data tables are semantically correct, so assistive technologies can present the content meaningfully to users.
When a table’s visual label is not associated using proper HTML semantics, its function and context are lost to non-visual users, creating a barrier to access.
The Algorithm (in simple terms)
-
Look for tables using a
<td>
or<th>
with acolspan
value that appears before table headers. -
Flag these if no actual
<caption>
element is present. -
Recommend replacing the visual label with a semantic
<caption>
.