Why it matters
- Icon buttons, such as add to cart, add to wishlist, search and close, show only a picture. Without a name, a screen reader announces each one as a button, and people cannot tell which does what.
- WCAG 2.2 asks that every control has a name that assistive technology can read (success criterion 4.1.2, level A).
Example
<button id="wishlist" type="button"><svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16"><circle cx="8" cy="8" r="8" /></svg></button>
<button id="wishlist" type="button" aria-label="أضف إلى المفضلة"><svg aria-hidden="true" width="16" height="16" viewBox="0 0 16 16"><circle cx="8" cy="8" r="8" /></svg></button>
How to fix
- Give each icon button a name in the page's language:
<button type="button" aria-label="أضف إلى المفضلة">…</button>. - Or put visible text in the button, beside the icon.
- Keep
aria-hidden="true"on the icon itself, so it is not read twice.
How we detect
- We render the page and run axe-core 4.13.0's
button-namerule in each engine. - It reports each
<button>whose accessible name is empty: no text, and noaria-label,aria-labelledbyortitle. Buttons written as<input type="button">and its kin are a different axe rule,input-button-name, which Arablyzer reads too. - It does not apply to pages without buttons.