Minimum Accessible SVG Icon
Here’s my archetype for an accessible SVG icon.
Here are the bits.
title
The title
tag is the alt
attribute of an svg
. These examples are conceptually identical:
desc
The desc
tag is an extension of the title
. If you’re wordy, be wordy here. If the title is clear, don’t feel the need to repeat yourself.
aria-labelledby
You’ll need to smooth over some of the quirks of assisted devices. aria-labelledby
is an attribute on your root SVG element that points devices to your accessible text and description.
Note that the aria-labelledby
attribute uses id
s to identify content, not the elements.
role
roles
help assisted devices identify the SVG as an image. Use role="img"
on the root SVG element and role="presentation"
on the path
.
Using ARIA to enhance SVG accessibility is the best article I’ve foundon this topic. It’s more technical. The author dives deep into each attribute and triggers specific browser support.