Rule
SVG accessible name
Inline SVG and role="img" graphics need an accessible name.
- Rule
svg-img-alt- WCAG 2.2
- 1.1.1 Non-text Content (opens in a new tab) (Level A)
- Severity
- Serious
What it checks
An element marked as a graphic, with role="img", graphics-document or graphics-symbol, needs a name. The rule accepts aria-labelledby, aria-label, a title attribute, and on an <svg> a <title> child. A graphic role with none of them fails.
Text inside the element does not name it: a graphic role takes its name from the author, not from its contents. Native <img> elements are left to the image alt rule.
When a person decides
An <svg> with no role and no name is sent for review. Some screen readers announce it as an unlabelled graphic, but the markup cannot show whether it is meaningful or decoration. It passes when it is nested inside another SVG, or sits inside a link or button that already has a name.
Example
Fails
<svg role="img" viewBox="0 0 120 24" width="120" height="24">
<path d="M12 2l3 7h7l-6 5 2 8-6-4-6 4 2-8-6-5h7z"/>
</svg>
Passes
<svg role="img" viewBox="0 0 120 24" width="120" height="24">
<title>Rated 4 out of 5</title>
<path d="M12 2l3 7h7l-6 5 2 8-6-4-6 4 2-8-6-5h7z"/>
</svg>
The engine is tested against both examples.
How to fix it
Add a <title> as the first child of the <svg>, or an aria-label. If the graphic only decorates, drop the role and add aria-hidden="true".
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.