Accessible icons and SVGs
Icons can be meaningful or decorative. Meaningful icons need an accessible name. Decorative icons should be hidden from assistive technologies so they do not add noise.
Generated CSS content can be especially unpredictable. Different browser and screen reader combinations may expose generated text differently, so it is useful to test the patterns you use.
Meaningful inline SVG icons
These examples use the same SVG search icon. The first two give the icon an accessible name. The last one does not.
<title> and aria-labelledby.role="img" and aria-label.Decorative inline SVG icons
If the visible text already explains the control or content, the icon is usually decorative. In that case, hide the SVG from screen readers.
aria-hidden="true".CSS generated icons
These icons are created with the CSS content property. Screen reader support for generated content has changed over time and can vary by browser.
content: "→" / "" so the arrow can be treated as decorative where supported.