Add captions to tables to explain their purpose.
- Provide a title in the
Although the purpose of some tables is fully established from the text of a publication and do not require additional context, this is not often the case. Tables are typically self-contained and may only be referenced in passing from the text. Adding a caption ensures that users are aware of the table's purpose.
Captions are like headings — they should be short and identify the specific purpose of the table.
There are two primary ways to add captions:
- Using a
- Wrapping the table in a
figureand adding a
caption element is an optional first element of a
Example 1). When a heading for the table is provide in the caption it is
visually rendered above the table in italics by default, but this styling can be changed.
figure element can also be used to associate a table with its caption. In this
figcaption element provides the caption (see Example
2. Unlike the table
caption element, a
figcaption can be either
the first or last element in a
Although it is possible to use the
aria-label attribute to add a caption for
a table (see Example 3), this method is only advisable when there is
absolutely no option to provide a visible label. The use of the
limits the caption to users of assistive technologies, and not all assistive technologies will
announce a caption marked up this way.