Visualisation without a caption
viz/caption-missing
- WCAG success criterion
- 1.1.1 (level A)
- Outcome class
- Automatic. An automated check that can report a confirmed violation.
- Area
- Accessibility, Content & Alternatives
- Default severity
- low
- axe-core rule
viz/caption-missing
Why we flag this
Nothing names the visualisation in a few words; those who cannot see it do not learn what it is about before reading through the text layer.
figure[data-viz] without a <figcaption> as a direct child.
What the rule checks
Scope. Every figure[data-viz] (opt-in convention) that is presented.
Expectation. A visualisation needs a <figcaption> as a direct child to be named (HTML: the figcaption child captions the figure): violation at the figure. A figcaption nested deeper is not the figure's caption and fails. A figure inside a hidden panel is not presented and is not judged (#725).
Source. Display-mode convention v0 (casoon/barrierlab#22) hung on WCAG 2.2 SC 1.1.1, 1.3.1, 2.2.2; HTML §4.4.12-13 figure/figcaption
Detection: shared; needs dom.
Failing example
The check reports a violation here. Corpus case display_modes_viz_static, element figure#globe. The page may contain further findings for other rules.
<!DOCTYPE html>
<!-- Display-mode convention, static rules shared with a11y-rules (#699): an
interactive visualisation without a still image and without a caption, a
chart whose values are only in a sentence, and one that does it right
(caption, still image, table). The toggle and data-display are in place,
so no display/* finding is expected besides the viz/* ones. -->
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Display modes: static rules</title>
<script>document.documentElement.dataset.display = 'visual';</script>
<style>
[data-viz-text] { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
#display-toggle { min-width: 44px; min-height: 44px; }
</style>
</head>
<body>
<header>
<nav aria-label="Display">
<select id="display-toggle" data-display-toggle aria-label="Display">
<option value="visual" selected>Visual</option>
<option value="calm">Calm</option>
<option value="text">Text</option>
</select>
</nav>
</header>
<main>
<h1>Earth systems</h1>
<figure id="globe" data-viz="interactive">
<canvas data-viz-live width="300" height="150" aria-hidden="true"></canvas>
<div data-viz-text><p>A globe showing ocean currents; drag to turn it.</p></div>
</figure>
<figure id="spark" data-viz="chart">
<svg data-viz-static aria-hidden="true" width="120" height="30" viewBox="0 0 120 30"><path d="M0 25 L120 5" stroke="#333" fill="none"></path></svg>
<div data-viz-text><p>Rises from 2 to 9 over the period.</p></div>
<figcaption>Trend</figcaption>
</figure>
<figure id="good" data-viz="chart">
<svg data-viz-static aria-hidden="true" width="120" height="30" viewBox="0 0 120 30"><path d="M0 25 L120 5" stroke="#333" fill="none"></path></svg>
<div data-viz-text>
<table>
<caption>Values</caption>
<tr><th scope="col">Year</th><th scope="col">Value</th></tr>
<tr><td>2000</td><td>2</td></tr>
<tr><td>2020</td><td>9</td></tr>
</table>
</div>
<figcaption>Values by year</figcaption>
</figure>
</main>
</body>
</html>Passing example
The check passes here and reports nothing. Corpus case content_viz_hidden_panel, element figure#archived-chart. The page may contain further findings for other rules.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Library in numbers: archived panel</title>
<script>document.documentElement.dataset.display = 'visual';</script>
<style>
html:not([data-display="text"]) [data-viz-text] {
position: absolute; width: 1px; height: 1px; overflow: hidden;
clip-path: inset(50%); white-space: nowrap;
}
body > a[href="#main"], #display-toggle { display: inline-block; min-width: 44px; min-height: 44px; }
</style>
</head>
<body>
<a href="#main">Skip to main content</a>
<header>
<nav aria-label="Display">
<label for="display-toggle">Display</label>
<select id="display-toggle" data-display-toggle>
<option value="visual" selected>Visual</option>
<option value="calm">Calm</option>
<option value="text">Text</option>
</select>
</nav>
</header>
<main id="main">
<h1>Library in numbers</h1>
<section aria-labelledby="this-year">
<h2 id="this-year">This year</h2>
<p>Figures for this year follow in spring.</p>
</section>
<section aria-labelledby="last-year" hidden>
<h2 id="last-year">Last year</h2>
<figure id="archived-chart" data-viz="interactive">
<canvas data-viz-live width="200" height="100" aria-hidden="true"></canvas>
<div data-viz-text><p>Loans fell slightly to 14,200.</p></div>
</figure>
</section>
</main>
<footer><p>City Library, 1 Market Square</p></footer>
</body>
</html>This page is generated from the rule catalogue and the rule contracts; see therule overview for how the outcome classes are derived.