Repository navigation
Web HIG tip #5: Every control needs an accessible name #13
frozonfreak
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
An icon button looks obvious to anyone who can see the icon. A screen reader user hears "button" and has to guess what it does.
Web HIG tip #5 (Quick #69, HIG-A11Y-004): Every control needs an accessible name. Icon-only buttons are where this breaks most often.
Why it matters
Icon-only controls are everywhere: delete, edit, close, menu, share. Without a name:
The rule of thumb
Ask: if the icon disappeared, would this control still say what it does?
If not, give it a name.
If the button already has visible text, like
<button><svg aria-hidden="true">…</svg> Delete</button>, the text is the name. Don't add anaria-labelto the icon or the button as well. If you ever do label a button that has visible text, the label must contain that text, so voice users can say what they see.Do this instead
<button>or link itself (anaria-labelor visually hidden text), and mark the iconaria-hidden="true"<button>, not a clickable<div>or<span>. A name on a<div>doesn't make it a button (see tip Add coding-agent workflow integration howto and templates #3)Quick check for your app
Tab through one screen with a screen reader on. Every control should be announced with a name that tells you what it does, and no icon button should come through as just "button". In browser dev tools, the Accessibility panel shows each control's computed name, so any empty one is a fix.
The Web HIG is a behavioral contract for how the web should behave, not a component library. Design systems define how it looks. The Web HIG defines how it behaves.
All reactions