Accessible SVG: naming a picture, hiding a decoration, and passing WCAG 1.1.1
An SVG is a picture, and a picture without a name is invisible to a screen reader in the sense that matters: the user knows something is there but not what it is, or hears nothing at all. WCAG 2.1 success criterion 1.1.1 asks for a text alternative for every non-text element, with an exception for pure decoration. Deciding which case applies is the first step, not the markup.
There are two legitimate states. A meaningful image needs a name, exposed through a title element, aria-label or aria-labelledby. A decorative image should be hidden from assistive technology with aria-hidden="true" and, for older browsers, focusable="false" so it cannot receive tab focus. What is not legitimate is an image that is neither named nor hidden, which is what most exported icons are.
| Goal | Markup | Notes |
|---|---|---|
| Meaningful inline SVG | role="img" + title or aria-label | Name goes on the svg |
| Icon inside a labelled button | aria-hidden="true" on the svg | Name belongs to the button |
| Standalone image file | <img src="icon.svg" alt="Save"> | alt is on the img, not the file |
| Decorative inline SVG | aria-hidden="true" focusable="false" | No name at all |
| Complex diagram | aria-labelledby="t d" + title + desc | desc carries the longer text |
title, desc and the order of children
A title element provides both the accessible name and the native tooltip. Browsers are inconsistent about which title they use when an SVG contains several, and the specification expects the first child of the root to be the one that names the graphic. Put it first, keep it short, and use desc for the longer explanation. Do not duplicate the visible caption word for word; the caption is already read by the screen reader.
The tooltip is a side effect, not a reason to add a title. A tooltip on a decorative icon is noise. If a tooltip is genuinely needed, a title is a reasonable way to get one, but a visible label or a proper tooltip component is usually better for keyboard and touch users.
Colour is not the only signal
SVG icons are often the only place a state is shown: a red error triangle, a green check, a grey disabled lock. WCAG 1.4.1 requires that colour is not the only visual means of conveying information. Pair the icon with text or a shape difference, and check the contrast of the stroke against its actual background in both themes. A light grey icon on white can pass a design review and fail a contrast audit.
Text inside an SVG has its own problems: it does not reflow, it does not respect the user's font size setting, and translation can overflow the viewBox. For labels and messages, use HTML text and let the SVG draw the graphic only. If text must be in the file, keep it short and leave room for expansion.
Reduced motion matters for animated SVG. A loading spinner that rotates forever can be stopped with a prefers-reduced-motion media query; WCAG 2.3.3 addresses motion that is not essential. Test with the setting on, not only in code.
Sources
Questions
Should an icon have alt text?
Only if it carries meaning. An icon button needs a name, usually on the button rather than on the svg. A decorative icon beside a text label should be hidden with aria-hidden="true" so the screen reader does not announce it twice. Repeating the adjacent text as a label is the most common mistake.
What is the difference between title and aria-label?
A title element gives the SVG an accessible name and a mouse tooltip, and it must be the first child of the svg to be used reliably. aria-label gives a name without a tooltip and overrides the title in most screen readers. Use one, not both, unless they say the same thing.
Does a viewBox help accessibility?
It helps scaling, which indirectly helps low-vision users who zoom. It does not provide a name. An SVG with no viewBox and fixed pixel width can clip when text is enlarged, so the viewBox is part of a generally robust component even though WCAG does not require it directly.
The accessibility panel in the optimizer flags a missing viewBox, name, role and title on any file you paste.
Open the optimizerWritten against the W3C SVG specifications, MDN and the React and WCAG documentation; every sample in the examples can be pasted into the optimizer linked above.
Back to the guides