How can I give an icon-only button an accessible name?
Quick answer
Give an icon-only button a concise programmatic name that describes its action, for example with aria-label="Search". An icon’s appearance alone is not a dependable name. When a button also has visible text, keep its accessible name inclusive of that wording; an overriding aria-label can replace the visible label in name calculation. Check the resulting name in the accessibility tree, and remember that a non-empty name alone does not prove it is accurate or useful. [S1] [S2]
The question, the details, the next step.
A practical checklist
Describe the button’s action, not merely the icon’s appearance.
Give an icon-only button a concise programmatic name.
When visible words are present, ensure the accessible name includes them.
Inspect the name exposed in the accessibility tree.
Check that the name is accurate and useful, not only non-empty.
A few more useful answers
Is a non-empty accessible name enough?
No. The cited ACT rule checks that a name exists, but does not establish that it is accurate or useful. Review the wording against the button’s actual purpose. [S1]
Can an `aria-label` conflict with visible button text?
Yes. aria-label can take precedence in name calculation and override visible text. Keep the accessible name inclusive of the visible label rather than omitting or contradicting it. [S2]
Sources
References used for this guide.
- [S1] W3C ACT Rule: Button has non-empty accessible name w3.org · Checked
- [S2] Understanding WCAG 2.2: Label in Name w3.org · Checked
