Rule

Canvas accessible name

Meaningful <canvas> graphics need an accessible name or fallback.

Rule
canvas-alt
WCAG 2.2
1.1.1 Non-text Content (opens in a new tab) (Level A)
Severity
Moderate

What it checks

A <canvas> with no role is a drawing surface that reaches assistive technology as nothing. Chart libraries draw into one by default. The rule looks at each canvas without a role and passes it when it has an accessible name, text fallback content inside the element, or sits inside a link or button that already has a name.

Canvases smaller than 32 by 32 pixels pass, since at that size they are usually decoration. Script and style inside the canvas do not count as fallback content.

When a person decides

A larger canvas with no name and no fallback is sent for review rather than failed. A background animation is decorative and needs nothing; a chart of figures is content and needs a text alternative. The markup cannot tell the two apart. A canvas with role="img" and no name is a failure, checked by the SVG accessible name rule.

Example

Sent to review

<h2>Sales by region</h2>
<canvas id="sales" width="600" height="300"></canvas>

Passes

<h2>Sales by region</h2>
<canvas id="sales" width="600" height="300">
  North 40%, South 35%, West 25%.
</canvas>

The engine is tested against both examples.

How to fix it

If the canvas only decorates, add aria-hidden="true". If it carries information, put a text version inside the <canvas>, or add role="img" with an aria-label that gives the same information.

Check your own pages

This rule runs in every pour audit: the browser extension, the bookmarklet, the command line and the editor. Get pour, free.