Briefly
Document structure role from WAI-ARIA for a visible caption for a table, regular or tree grid, and standalone graphic content.
In HTML, this role is automatically present on <caption>
.
How to Write
Assign the tag role
, preferably to <div>
or <span>
. However, for a <table>
it is best to use <caption>
primarily, and for a <figure>
— <figcaption>
.
Elements with caption
can describe only some elements and ARIA roles:
The caption
element must be nested within containers with the roles figure
, table
, grid
, and treegrid
. For table
, grid
, and treegrid
, the description should be the first child element, and for figure
— either the first or the last.
To link the caption to the role caption
and the element it relates to, set aria
on the parent element and id
with the same value for the caption
. If you want to add additional detailed description, it can also be nested within the caption
and linked to the main element using aria
.
For elements with the role caption
, all global ARIA attributes can be used.