SVG Accessibility
Every SVG on your page falls into one of two categories from a screen reader's perspective: decorative or informative. Decorative SVGs exist to support content that is already described elsewhere. Informative SVGs carry meaning that would be lost without them. Getting this distinction right is the foundation of accessible icon work. The mechanics that follow from it: which attributes to add, which to omit, how to handle buttons and links. All of these depend on answering that one question first.
Decorative SVGs
A decorative SVG adds visual interest or reinforces meaning that is already communicated in nearby text. A checkmark icon next to the word "Complete", a home icon inside a nav link that already says "Home", a decorative divider between sections. These all fall into this category. Screen readers should skip them entirely.
Two attributes work together to hide an SVG from assistive technology:
<svg aria-hidden="true" focusable="false">
<use href="#icon-check"></use>
</svg>
-
aria-hidden="true"removes the element and all its children from the accessibility tree. Screen readers will not announce it. -
focusable="false"is needed for Internet Explorer and older Edge, which made SVGs focusable by default. Modern browsers do not require it, but it is harmless and worth including for robustness.
aria-hidden on a Focusable Element
aria-hidden="true" hides the element from the accessibility tree but does not remove it from tab order. If the SVG itself or a child element is focusable, keyboard users can still tab to it while screen reader users hear nothing. Always ensure aria-hidden elements are not focusable.
role="img" and title
When an SVG conveys meaning that is not communicated anywhere else on the page, it must be labeled. A standalone icon that represents an action, a logo, a chart, or a status indicator all fall into this category.
The pattern for a labeled SVG uses three parts: role="img" to identify it as an image to assistive technology, a <title> element as the first child of the SVG with the accessible name, and aria-labelledby connecting the outer SVG to that title by ID:
<svg role="img" aria-labelledby="icon-title-star">
<title id="icon-title-star">Favorite</title>
<use href="#icon-star"></use>
</svg>
Without role="img", some screen readers treat the SVG as a group and announce its contents differently across browsers. Without aria-labelledby, some screen readers ignore the <title> entirely. Using all three together produces consistent behavior across NVDA, JAWS, and VoiceOver.
title vs. desc
<title> provides the accessible name: the short label that identifies what the SVG is. <desc> provides a longer description for complex graphics like charts or diagrams where the title alone is not sufficient. For icons, <title> alone is almost always enough. Add <desc> only when the SVG communicates data or spatial relationships that require more than a few words to convey.
<!-- Icon: title only -->
<svg role="img" aria-labelledby="chart-title chart-desc">
<title id="chart-title">Monthly Revenue</title>
<desc id="chart-desc">
Bar chart showing revenue from January through June.
June was the highest month at $42,000.
</desc>
<!-- chart paths -->
</svg>
The Decision Tree
Before adding any accessibility attributes to an SVG, work through these questions in order:
-
Is the SVG purely decorative? If yes: add
aria-hidden="true"andfocusable="false". Stop here. -
Is the SVG inside a button or link that already has a visible text label? If yes: the button or link label covers the icon. Add
aria-hidden="true"to the SVG. Stop here. -
Is the SVG inside an icon-only button or link with no visible text? If yes: label the button or link with
aria-labeloraria-labelledby. Addaria-hidden="true"to the SVG itself since the interactive element carries the label. Stop here. -
Is the SVG a standalone informative image? If yes: add
role="img", a<title>as the first child, andaria-labelledbypointing to the title ID.
Pairing SVGs with Links and Buttons
Icons inside interactive elements need careful handling. The goal is always that the interactive element announces exactly one clear label: not the icon's title, not a redundant combination of icon and text, and not silence.
Icon with Visible Text Label
When a button or link has visible text alongside the icon, the text provides the accessible name. Hide the icon:
<button type="button">
<svg aria-hidden="true" focusable="false">
<use href="#icon-arrow-right"></use>
</svg>
Continue
</button>
<!-- Announced: "Continue, button" -->
Icon-Only Button
When there is no visible text, the interactive element itself needs a label. Use aria-label on the button or link, and hide the SVG:
<button type="button" aria-label="Close dialog">
<svg aria-hidden="true" focusable="false">
<use href="#icon-close"></use>
</svg>
</button>
<!-- Announced: "Close dialog, button" -->
An alternative to aria-label is visually hidden text inside the button. This approach is more robust for translation tools and some AT configurations:
<button type="button">
<svg aria-hidden="true" focusable="false">
<use href="#icon-close"></use>
</svg>
<span class="visually-hidden">Close dialog</span>
</button>
The visually-hidden class is already defined in this course site's utilities stylesheet. You do not need to rewrite it for each project. See CSS Architecture for how utility classes fit into the layer stack.
aria-label vs. Visually Hidden Text
Both approaches work. aria-label is quicker to write. Visually hidden text is picked up by browser translation features like Chrome's built-in translator, which ignores aria-label values. For a student project either is acceptable; in production, visually hidden text is generally preferred.
Icon-Only Link
The same pattern applies to links. A social media icon link with no visible text needs a label on the <a> element:
<a href="https://github.com/username" aria-label="GitHub profile">
<svg aria-hidden="true" focusable="false">
<use href="#icon-github"></use>
</svg>
</a>
<!-- Announced: "GitHub profile, link" -->
Accessibility in Action
The demo below uses the same inline sprite and <use> pattern from SVG Sprites. Pick a scenario to see a live example, what pattern it follows, and what a screen reader should announce. The announcement text is guidance only; run a real screen reader test using the checklist later on this page.
Decorative Beside Text
The nearby text already conveys the meaning. Hide the SVG with aria-hidden="true" and focusable="false" so assistive technology skips it.
Expected Announcement
Guidance only. Your screen reader may phrase this differently.
Your order is confirmed.
use and the Shadow DOM
The <use> element renders a clone of its referenced symbol inside a shadow DOM. This creates a subtle accessibility problem: a <title> element placed inside a <symbol> definition is not reliably exposed through the shadow DOM to assistive technology. Screen readers in some browser and AT combinations will not announce it.
The practical implication is that you should not rely on titles inside <symbol> definitions for accessibility. Instead, place the accessible label on the <svg> wrapper that contains <use>, either with aria-label directly or with a <title> in the wrapper SVG itself:
<!-- Unreliable: title inside symbol -->
<symbol id="icon-star" viewBox="0 0 24 24">
<title>Star</title> <!-- May not be exposed through use -->
<path d="..."></path>
</symbol>
<!-- Reliable: label on the wrapper SVG -->
<svg role="img" aria-label="Favorite">
<use href="#icon-star"></use>
</svg>
Screen Reader Quick Test
You do not need a full assistive technology setup to do a basic screen reader test. Every major operating system ships with one built in:
- macOS and iOS: VoiceOver. Enable with Command + F5 on Mac, or triple-click the side button on iPhone. Navigate with Tab and arrow keys on Mac; swipe on iOS.
- Windows: Narrator is built in (Windows key + Ctrl + Enter). NVDA is free to download and more representative of real-world screen reader usage.
- Android: TalkBack. Enable in Accessibility settings.
For icons specifically, listen for these things during your test:
-
Decorative icons: should be completely silent. If VoiceOver or NVDA announces anything when you navigate past the icon,
aria-hidden="true"is missing or applied incorrectly. -
Icon-only buttons: should announce the button label you provided, followed by "button." If you hear "button" with no label, the
aria-labelor visually hidden text is missing. - Icon-only links: should announce the link label followed by "link." Same as above if you hear only "link."
-
Informative standalone SVGs: should announce the
<title>text followed by "image." If you hear nothing, checkrole="img"andaria-labelledby.
Screen reader and browser combinations behave differently. VoiceOver with Safari is the primary combination on Mac and iOS. NVDA with Firefox or Chrome covers most Windows users. A test that passes in one combination can fail in another, so checking two is a meaningful minimum.
Check Your Understanding
A student just completed a learning activity on SVG accessibility. They learned the decorative versus informative distinction and when to apply each pattern, how to use aria-hidden and focusable="false" on decorative icons, how to label informative SVGs with role="img" and aria-labelledby pointing to a title element, how to handle icon-only buttons and links with aria-label or visually hidden text, why titles inside symbol definitions are unreliable through the use shadow DOM, and how to do a basic screen reader quick test. They also worked through the Accessibility in Action demo scenarios: decorative beside text, button with visible label, icon-only button, icon-only link, and standalone informative SVG. The challenge gives them broken markup to fix. Review their corrections and give direct feedback. Tell them what they fixed correctly and what they missed or fixed incorrectly. Check that decorative icons have aria-hidden="true" and focusable="false", that the icon-only button has a label on the button element rather than inside the SVG, that the standalone informative SVG has role="img" and aria-labelledby pointing to a title with a matching ID, and that no focusable elements have aria-hidden on them. Watch for common mistakes like putting aria-label on the SVG instead of the button, using aria-hidden on the button itself, relying on a title inside the symbol definition, or missing focusable="false". Guide them back to the concepts rather than providing complete solutions.
<!--
The markup below has multiple accessibility problems.
Fix every issue you find.
Hint: there are at least four distinct problems.
-->
<!-- 1. Decorative icon next to a text label -->
<p>
<svg>
<use href="#icon-check"></use>
</svg>
Your order is confirmed.
</p>
<!-- 2. Icon-only close button -->
<button type="button">
<svg role="img" aria-label="Close">
<use href="#icon-close"></use>
</svg>
</button>
<!-- 3. Standalone informative icon -->
<svg>
<use href="#icon-warning"></use>
</svg>
<!-- 4. Icon-only nav link -->
<a href="/home">
<svg aria-label="Home">
<use href="#icon-home"></use>
</svg>
</a>
Resources
- MDN: ARIA img role — When and how to use role="img" on SVG and other non-image elements
- MDN: SVG title — The accessible name element for SVG, including its relationship to aria-labelledby
- Smashing Magazine: Accessible SVG Patterns — Detailed comparison of every SVG accessibility pattern with screen reader test results across browsers
- WebAIM: Keyboard Accessibility — Keyboard navigation patterns and how screen readers interact with focusable elements