SVG Accessibility: Titles, Labels and Decorative Icons
SVG accessibility comes down to one decision per graphic: does it carry meaning, or is it decoration? If it carries meaning, give it a text alternative, such as a <title> or an aria-label. If it is decoration, hide it from assistive technology so screen reader users do not hear noise. This guide shows the markup for both cases, how to label icon buttons, and how to check the result.
- Informative SVG needs a name:
role="img"plus a<title>referenced witharia-labelledby, or anaria-label. - Decorative SVG should use
aria-hidden="true"(inline) or an emptyalt=""(in an<img>). - An icon inside a button does not need its own label if the button already has visible text; an icon-only button needs an accessible name.
- A
<title>tooltip alone is not a reliable accessible name for everyone. - Always test with a real screen reader and the browser's accessibility inspector.
Informative vs Decorative SVG: Decide First
An SVG is informative when removing it would make the page harder to understand, and decorative when it only adds visual polish. A chart, a logo that identifies a brand, or a warning icon that is the only sign of an error are informative. A flourish next to a heading, or an arrow beside a link that already says "Next page", is decorative.
A quick test: imagine the page read aloud with all images removed. If something important goes missing, the graphic needs a text alternative. If nothing is lost, hide it.
How to Add an Accessible Name to Inline SVG
For inline SVG, the common pattern is to put role="img" on the <svg>, add a <title> as its first child, and point aria-labelledby at the title's id. Screen readers then treat the graphic as a single image with that name instead of trying to read its shapes.
<svg role="img" aria-labelledby="chart-title" viewBox="0 0 120 60"
xmlns="http://www.w3.org/2000/svg">
<title id="chart-title">Sales grew from 40 to 90 units over six months</title>
<polyline points="0,50 40,40 80,25 120,10" fill="none"
stroke="currentColor" stroke-width="3"/>
</svg>
The role="img" part matters because without it some screen reader and browser combinations may treat the SVG as a generic group and announce child elements separately. The aria-labelledby part is a belt-and-braces measure: support for a bare <title> has historically been uneven, and the explicit reference generally makes the name more dependable.
Keep the name short: say what the graphic communicates, not what it looks like.
Using aria-label instead of title
If you do not need a visible tooltip or a structured description, aria-label on the SVG is simpler. It is a single attribute and gives the graphic its name directly.
<svg role="img" aria-label="Verified account" viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg">
<path d="M9 16.2 4.8 12l-1.4 1.4L9 19 21 7l-1.4-1.4z"/>
</svg>
Both approaches are valid. Using <title> keeps the label inside the SVG file, which is handy if the same markup is copied between pages. Using aria-label keeps the markup shorter, and it is easier to set from a component prop.
Adding a longer description with desc
For complex graphics such as charts and diagrams, a short name is not enough. You can add a <desc> element and reference both ids, for example aria-labelledby="t d". Often a better solution is to put the full explanation in the page text, or a data table beside the chart, because that works for everyone and can be searched.
How to Hide Decorative SVG Icons
Inline decorative icons
Decorative inline SVG should carry aria-hidden="true", which removes it from the accessibility tree so screen readers skip it. Do not add a title or label to it.
<a href="/pricing">
See pricing
<svg aria-hidden="true" focusable="false" viewBox="0 0 24 24"
width="16" height="16" xmlns="http://www.w3.org/2000/svg">
<path d="M8 5l8 7-8 7z"/>
</svg>
</a>
The link is announced as "See pricing" and the arrow is ignored. The focusable="false" attribute was needed to stop old Internet Explorer and early Edge versions from putting SVGs in the tab order. Modern browsers do not need it, so you can leave it out unless you still support those versions.
Be careful not to put aria-hidden="true" on anything focusable or on a container that holds links or buttons, because the element can then be reachable by keyboard yet invisible to a screen reader.
Accessibility for SVG used in an img tag
When an SVG is loaded as an external file through <img>, you describe it with the alt attribute like any other image. Markup inside the file, including a <title>, is generally not exposed to the page's accessibility tree in that mode, so the alt text is what counts.
<!-- Informative -->
<img src="/images/logo.svg" alt="ToSVG home">
<!-- Decorative -->
<img src="/images/divider.svg" alt="">
An empty alt="" tells assistive technology to skip the image. Leaving alt out entirely is different: some screen readers may then read the file name, which is rarely helpful. The same applies to SVG set as a CSS background: it has no text alternative, so use backgrounds only for decoration. Our comparison of inline SVG, img and CSS backgrounds explains how each embedding method behaves.
Icon buttons and links need an accessible name
A button that contains only an icon has no name unless you provide one, so a screen reader may announce just "button". Add the name to the button, not to the icon, and hide the icon.
<button type="button" aria-label="Close dialog">
<svg aria-hidden="true" viewBox="0 0 24 24" width="20" height="20"
xmlns="http://www.w3.org/2000/svg">
<path d="M6 6l12 12M18 6L6 18" stroke="currentColor" stroke-width="2"/>
</svg>
</button>
If you prefer visible text for everyone, put the words next to the icon. Another common technique is visually hidden text inside the button, using a CSS class that clips the text off-screen but leaves it readable by screen readers. Either way, the accessible name should describe the action ("Close dialog", "Download PDF"), not the picture ("X").
The same rule applies to links: an icon-only link to a social profile should be named after the destination, such as "ToSVG on GitHub". If you use icons from a library, the guide on using SVG icons in web projects covers the practical side of embedding them.
Contrast, Color and Motion
Accessible SVG is not only about screen readers. Low-vision users and people who are colorblind rely on the visuals being clear, so check contrast and avoid using color as the only signal.
- Contrast: WCAG asks for a contrast ratio of at least 3:1 for meaningful graphical objects such as icons and chart lines against their background. Check your colors with a contrast checker.
- Not color alone: if a chart uses red and green lines, add labels, patterns, different line styles or markers so the series can still be told apart.
- currentColor: using
fill="currentColor"lets an icon inherit the text color, so it follows your theme and any high-contrast settings you have designed. - Reduced motion: if your SVG animates, respect the user's system preference with a media query and switch the animation off or shorten it.
@media (prefers-reduced-motion: reduce) {
.spinner {
animation: none;
}
}
Also make sure the graphic stays legible when scaled. A correct viewBox lets people zoom the page without the icon breaking, which is covered in our viewBox guide.
How to Test SVG Accessibility
The most reliable test is to listen to the page with a screen reader, then confirm what the browser exposes with its developer tools. Work through these steps for each new kind of graphic you add.
- Open the browser's accessibility inspector. Chrome, Edge and Firefox all offer an accessibility tree or accessibility panel in their developer tools. Select the SVG and check its role and name.
- Confirm decorative icons are absent. A hidden icon should not appear in the tree, or should be marked as ignored.
- Turn on a screen reader. VoiceOver on macOS and iOS, TalkBack on Android, NVDA on Windows and Narrator are common choices. Move through the page and listen.
- Tab through the page. Every button and link, including icon-only ones, should announce a clear name and a role.
- Repeat in a second browser or screen reader. SVG naming support may differ between combinations, which is another reason to use the explicit patterns above.
Automated checkers can catch missing names and low contrast, but they cannot judge whether a name is meaningful.
Common SVG Accessibility Mistakes
Most problems repeat from project to project. These are the ones worth looking for in an audit.
Relying on a title tooltip
A <title> often shows a tooltip when you hover over the graphic, but hover does not exist on touch screens or for keyboard users. Treat the tooltip as a bonus and set the name properly.
Duplicate announcements
If a link says "Download report" and contains an icon labeled "Download", a screen reader may say "Download Download report". Hide the icon with aria-hidden="true" and let the text speak.
Labeling decorative graphics
Adding aria-label to every icon feels thorough but creates clutter. A page with thirty labeled bullet icons is tiring to listen to. If the icon repeats what the adjacent text says, hide it.
Losing the title during optimization
Some SVG optimizers remove <title> and <desc> elements by default, because they count as non-essential metadata. After running any optimizer, including the ToSVG SVG optimizer, check that the accessible name you rely on is still there. If you set the name through aria-label in your page markup, it will not be affected, which is one reason that approach suits components. For background on size reduction, see SVG optimization techniques, and for how metadata is handled, read understanding SVG metadata and accessibility in ToSVG outputs.
Frequently Asked Questions
Should I use title or aria-label for SVG?
Either can work. Use role="img" with a <title> and aria-labelledby when the label should travel with the SVG file, and aria-label when the name is set from your page or component code.
How do I hide a decorative SVG from screen readers?
Add aria-hidden="true" to inline SVG, or use alt="" on an <img>. Do not give a decorative graphic a title or label.
Does a screen reader read the text inside an SVG?
It may. Text elements in inline SVG can be exposed to assistive technology, which is why role="img" with a name is used to present the graphic as one object. If the text inside is important, make sure it is also part of the name or the surrounding page text.
Do SVG images in an img tag need alt text?
Yes. Treat them like any other image: meaningful alt text for informative graphics and an empty alt="" for decorative ones.
Is SVG better than PNG for accessibility?
SVG can offer more, because inline SVG can use text, titles and theme colors, and it scales cleanly for zoom. But neither format is accessible by default; the markup around it decides.
Once your labels are in place, keep your files lean without losing them: run your graphics through the ToSVG SVG optimizer and check the result in your accessibility inspector.