Rampsight

All rules

Tables

Use a real caption

Why it matters

A first row styled to look like a title is read as a data cell. The table gets no caption, and the row corrupts the column structure for everyone reading it cell by cell.

How to fix it

  1. Move the text into a <caption> element as the first child of the <table>.
  2. Style the caption with CSS if it needs to look like the old row.
  3. Remove the spanning row afterwards so the column count is honest.

In markup

Fails
<table>
  <tr><td colspan="3"><strong>Q3 revenue</strong></td></tr>
  <tr><th>Region</th><th>Q3</th><th>Q4</th></tr>
</table>
Passes
<table>
  <caption>Q3 revenue</caption>
  <tr><th>Region</th><th>Q3</th><th>Q4</th></tr>
</table>

The requirement behind it

This rule is one way of failing the following WCAG 2.2 success criteria. The W3C, which writes the standard, explains each of them:

Further reading

Deque University on table-fake-caption (opens in new tab)

Deque maintains axe-core, the open-source engine our scanner runs. Their page documents the rule as the engine implements it.

Automated checks find failures a browser can prove. They cannot judge whether a caption is accurate, whether an alt text is useful, or whether a page can be operated end to end with a keyboard — those need a person.