Accessible SVG icons
Decide: decorative or meaningful?
Most icons sit next to a text label ("Settings", "Download"). They are decorative: the text already says everything, and a screen reader announcing the icon too is noise. Icons that appear without text (an icon-only button, a status dot) carry meaning and need an accessible name.
Decorative icons: hide them
<button type="button">
<svg aria-hidden="true" focusable="false" viewBox="0 0 24 24" width="20" height="20">…</svg>
Download
</button>aria-hidden="true" removes the icon from the accessibility tree. focusable="false" is only needed for old Internet Explorer and Edge, but is harmless. For <img> icons, use an empty alt="".
Icon-only buttons and links: name the control
<button type="button" aria-label="Search">
<svg aria-hidden="true" viewBox="0 0 24 24" width="20" height="20">…</svg>
</button>Put the name on the button, not the SVG, so it works with every screen reader. A visually hidden <span> with the label is equally good and also translates with the page. A title tooltip alone is not a reliable accessible name.
Standalone meaningful icons
<svg role="img" aria-label="Payment verified" viewBox="0 0 24 24" width="24" height="24">…</svg>Use role="img" with aria-label (or a <title> referenced by aria-labelledby) when an icon conveys information on its own. Describe the meaning ("Payment verified"), not the drawing ("green shield").
Contrast and size
- Contrast: WCAG 2.2 success criterion 1.4.11 asks for at least 3:1 contrast between meaningful icons and their background. Decorative icons are exempt.
- Target size: criterion 2.5.8 (level AA) asks for interactive targets of at least 24×24 CSS pixels, or enough spacing. Apple's guidelines recommend 44×44 points for touch. A 20px icon inside a 44px button is fine.
- Don't rely on colour alone: a red and a green dot look the same to many people. Pair status colours with different shapes (check, cross) or text.
Frequently asked questions
Should SVG icons have alt text?
Only if they carry meaning on their own. Decorative icons next to text should be hidden with aria-hidden="true" (inline SVG) or alt="" (img).
Is the <title> element enough to label an SVG?
Not on its own in every browser and screen reader. Use role="img" with aria-label, or reference the <title> with aria-labelledby.
What contrast do icons need?
Meaningful icons need at least 3:1 against the background under WCAG 1.4.11. Decorative icons have no contrast requirement.