Why it matters
- A screen reader reads a link by its name: its text, the
altof its image, or itsaria-label. An icon link without one is announced as a link and nothing more, and people cannot tell the cart from the account page. - People who move through a page by its list of links see an empty entry.
- WCAG 2.2 asks that the purpose of each link can be told (success criterion 2.4.4, level A) and that every control has a name (4.1.2, level A).
Example
<a id="cart" href="/cart"><svg aria-hidden="true" width="24" height="24" viewBox="0 0 16 16"><rect width="16" height="16" /></svg></a>
<a id="cart" href="/cart" aria-label="السلة"><svg aria-hidden="true" width="24" height="24" viewBox="0 0 16 16"><rect width="16" height="16" /></svg></a>
How to fix
- Give icon links a name in the page's language:
<a href="/cart" aria-label="السلة">…</a>, or visible text beside the icon. - For a linked image, write its
alt:<a href="/"><img src="logo.svg" alt="متجر الواحة"></a>. - Keep
aria-hidden="true"on decorative icons inside links that already have text.
How we detect
- We render the page and run axe-core 4.13.0's
link-namerule in each engine. - It reports each link whose accessible name is empty: no text, no image
alt, and noaria-label,aria-labelledbyortitle. - It does not apply to pages without links.