Accessible SVGs
debt(d4/e3/b3/t6)
Closest to 'default linter catches the common case' (d3) +1. Tools like axe and Lighthouse (listed in detection_hints) can detect missing aria-hidden on decorative SVGs and missing role/title on informative SVGs automatically. However, they cannot fully distinguish decorative from informative SVGs without developer intent, and interactive SVG patterns (charts, keyboard handlers) require manual review. The automated coverage is good but not complete, so d4.
Closest to 'simple parameterised fix' (e3). The quick_fix shows that decorative SVGs need a single attribute (aria-hidden=true), and informative SVGs need role=img + aria-label or title+desc — these are small, localized additions per SVG element. However, if there are many SVGs across templates, it touches multiple files but each fix is mechanical. Interactive SVGs requiring full ARIA widget patterns push higher, but the common cases are e3-level fixes.
Closest to 'localised tax' (b3). This applies only to the web context and affects individual SVG elements in templates/components. It's not an architectural choice — it's a per-element concern. However, every new SVG added to the project needs to follow the pattern, creating a small ongoing tax for front-end developers. It doesn't shape the system's architecture or affect non-UI code.
Closest to 'notable trap' (t5) +1. The misconception is telling: developers assume SVG icons are automatically read correctly by screen readers, when in fact browsers may read file paths or class names. This is a genuine surprise — the 'obvious' approach (just drop in an SVG) produces bad results silently. The additional trap that <title> must be the first child of <svg> to work, and that different browsers handle SVG accessibility inconsistently, adds to the cognitive load. It contradicts the mental model from <img alt='...'> where there's one clear pattern, pushing this to t6.
Also Known As
TL;DR
Explanation
Decorative (icon in labelled button): aria-hidden=true. Informative (standalone chart): role=img, aria-labelledby pointing to title inside SVG. Interactive: full ARIA widget pattern. Inline SVG: add title as first child, desc for description, aria-labelledby to title id. Img tag SVG: alt attribute works normally.
Watch Out
Common Misconception
Why It Matters
Common Mistakes
- No aria-hidden on decorative SVGs
- No alt on informative SVGs
- title not first child of svg
Avoid When
- Do not add aria-label to a decorative SVG already inside a button with visible text — it creates redundant announcements.
- Avoid embedding critical data only inside SVG paths with no text alternative — screen readers cannot parse drawn content.
When To Use
- Add aria-hidden="true" to purely decorative SVGs — icons inside labelled buttons, dividers, background flourishes.
- Add role="img" and aria-label (or <title>+<desc>) to informative SVGs that convey meaning independently.
- For interactive SVGs (charts, maps), add focusable elements with keyboard handlers and descriptive labels.
Code Examples
<button><svg><!-- icon --></svg>Search</button>
<button><svg aria-hidden="true" focusable="false"><!-- icon --></svg>Search</button>
<svg role="img" aria-labelledby="t"><title id="t">Monthly Revenue</title></svg>