Documentation/Tables need captions

Tables need captions

ZMD008

Each <table> must start with a <caption> that concisely describes its purpose or content.

✅ Good

<table>
  <caption>List of team members</caption>
  <tr><td>Jane</td><td>Doe</td></tr>
</table>

❌ Bad

<table>
  <tr><td>Jane</td><td>Doe</td></tr>
</table>

When: A <table> element lacks a <caption> child

Warning: <table> missing <caption>

Solution: Include a <caption> describing the table

Why it matters

Accessibility: Tables without captions provide no context for screen-reader users and break data navigation.

SEO: Omitting captions removes valuable descriptive keywords that aid search engine indexing of table data.

In brief

  • Goal: Provide a programmatic title for data tables.
  • What to do: Include a <caption> as the first child of every <table>.
  • Why: Captions act like headings for tables, enabling screen-reader users to identify table purpose quickly.

Intent

Ensure data tables are self-describing, improving accessibility and maintenance.

Benefits

  • Screen-reader users can navigate directly to table captions and understand context.
  • Visual users see a clear title for complex tables, enhancing comprehension.
  • Search engines index caption text, boosting table visibility in search results.

Techniques

  • H39: Using caption elements to associate data table captions programmatically.
  • ARIA table: For non-standard tables, use role="table" and aria-labelledby referencing a caption element.

HTML Semantics

The HTML `<caption>` element defines a title for a table; it must be the first child of `<table>` to remain linked semantically.

Tips & edge cases

  • Keep captions short—treat them like table titles rather than descriptions of every cell.
  • Ensure each caption is unique on a page to prevent confusion among multiple tables.
  • When nesting tables in <figure>, consider <figcaption> instead of <caption> for authoring flexibility.