Accessibility
a11y/control-name
Every button and link has an accessible name; icon-only controls get visually hidden text or aria-label.
criticalstaticWCAG 4.1.2, 2.4.4 · Afe-a11y-aria
Why
A button with only an icon is announced as "button" and nothing else. Screen reader and voice control users cannot tell what it does or say its name to activate it.
Fix
Prefer visible text. For an icon-only control, add text that is hidden visually but read (<span class="sr-only">Close</span>) or aria-label="Close", and mark the icon aria-hidden="true". A linked image names the link through its alt. Use the same word people see in tooltips and elsewhere on the site.
Examples
<!-- bad -->
<button type="button"><svg aria-hidden="true">…</svg></button>
<!-- good -->
<button type="button" aria-label="Close"><svg aria-hidden="true">…</svg></button>
<button type="button"><svg aria-hidden="true">…</svg><span class="sr-only">Close</span></button>Sources
Facts
- Id
a11y/control-name- Severity
- critical
- Check
- static checked in the source by
audit - Applies to
htmlangularvuesvelteastrojsx- WCAG 2.2
- 4.1.2, 2.4.4, level A
- Same problem in
- axe-core
button-name, axe-corelink-name, axe-coreinput-button-name, Lighthousebutton-name, Lighthouselink-name - Taught by the skill
fe-a11y-ariaARIA, names and live regions- Since version
- 0.1.0
Read it in the terminal
npx github:dawidolko/frontend-skills explain a11y/control-name