Goal
Ensure that SVG images added directly into the HTML file have a text alternative for screen reader users and other scenarios.
Why this matters
If the image’s meaning is not conveyed through the title or some other text alternative, not only is its meaning lost, but a screen reader will either ignore it or replace it with a string of garbage text as a result. See Writing for Screen Readers for an example.
The <title>
element provides a text alternative for the image.
How to implement
Ensure that the first child of the <svg>
is a <title>
containing the alternative text for the image. Depending on what software you used to create the SVG, you may need to move the title to directly under the <svg>
tag.
Work with your Writer for an appropriate title. If you don’t provide the alt text, Many applications will default to either the file name or the layer name, neither of which are useful to your end user.
How to test
- Right-click the SVG and use the Inspect feature to confirm the first child of the
<svg>
is a<title>
element. - Assuming it does, ensure that the title matches your Writer’s expectations.
Additional Resources
- Accessible SVGs: Perfect Patterns For Screen Reader Users by Carie Fisher