Similar benefits can be gained from grouping and naming other types of related form fields using fieldset
and legend
.
-
- The accessible name for the HTML table
and figure
elements can be derived from a child caption
or figcaption
element, respectively.
- Tables and figures often have a caption to explain what the table of figure is about, how to read them, and sometimes giving them numbers to be able to refer to them in surrounding prose. This can help users navigate and understand the content better. This is generally useful for all users, but especially for users of assistive technologies.
- In HTML, the table
element marks up a data table, and can be provided with a caption using the caption
element.
+
+ The accessible name for HTML table
and figure
elements can be derived from a child caption
or figcaption
element, respectively.
+ Tables and figures often have a caption to explain what they are about, how to read them, and sometimes giving them numbers used to refer to them in surrounding prose.
+ Captions can help all users better understand content, but are especially helpful to users of assistive technologies.
+
+
+ In HTML, the table
element marks up a data table, and can be provided with a caption using the caption
element.
+ If the table
element does not have aria-label
or aria-labelledby
, then the caption
will be used as the accessible name.
+ For example, the accessible name of the following table is Special opening hours
.
+
<table>
<caption>Special opening hours</caption>
<tr><td>30 May <td>Closed
@@ -4820,12 +4811,23 @@
Note: Above table content is from Caloric restriction, the traditional Okinawan diet, and healthy aging: the diet of the world's longest-lived people and its potential impact on morbidity and life span.
- Similarly, the HTML figure
element can be given a caption using the figcaption
element. The caption can appear before or after the figure, but it is more common for figures to have the caption after.
+
+ If a table
is named using aria-label
or aria-labelledby
, then a caption
element, if present, will become an accessible description.
+ For an example, see Describing Tables and Figures with Captions.
+
+
+ Similarly, an HTML figure
element can be given a caption using the figcaption
element.
+ The caption can appear before or after the figure, but it is more common for figures to have the caption after.
+
<figure>
<img alt="Painting of a person walking in a desert." src="Hole_JesusalDesierto.jpg">
<figcaption>Jesus entering the desert as imagined by William Hole, 1908</figcaption>
</figure>
-
+
+ Like with table
elements, if a figure
is not named using aria-label
or aria-labelledby
, the content of the figcaption
element will be used as the accessible name.
+ However unlike table
elements, if the figcaption
element is not used for the name, it does not become an accessible description unless it is referenced by aria-describedby
.
+ Nevertheless, assistive technologies will render the content of a figcaption
regardless of whether it is used as a name, description, or neither.
+
Using the caption
element to name a table
element, or a figcaption
element to name a figure
element, satisfies Rule 2: Prefer Visible Text and Rule 3: Prefer Native Techniques.
@@ -4833,7 +4835,8 @@