SiteCheck

Guides · Accessibility

How to name links and buttons

Links or buttons on your page have no name, often because they are icons: a magnifying glass, a cart or a social media logo. Sighted visitors can guess what the icon does. A screen reader finds no words, so it may only say "link" or "button", and the person listening cannot tell where it goes.

What a name is

The name is the text a browser passes to screen readers and voice control software. It usually comes from the words inside the link or button. An icon has no words, so you have to supply them.

Your report can raise this in two ways. One is a missing name. The other is a name that differs from the words on screen. People using voice control say what they see, for example "click Buy now". If the hidden name is "Purchase", that command may not work.

How the code decides what a screen reader saysThree versions of a control. A cart icon with no name is announced only as a link. The same icon with an aria-label is announced as Cart. A Buy now button named Purchase does not match its visible words. <a href="/cart"><svg/></a> Screen reader says: "link" Problem: no name <a href="/cart" aria-label="Cart"> Screen reader says: "Cart, link" Good: the name says where it goes Buy now aria-label="Purchase" Saying "click Buy now" may do nothing Problem: name differs from the words
The exact words a screen reader says vary by product. The name it reads comes from the code.

How to fix it

  1. Open your report and look at which links or buttons it lists.
  2. Decide what each one does and write that in a few words, such as "Search" or "Follow us on Instagram".
  3. Add the name using one of the methods below.
  4. If the control has visible words, make sure the name contains them, ideally at the start.

Pick the method that suits the control:

<a href="/cart" aria-label="Cart">
  <svg aria-hidden="true">...</svg>
</a>

<button type="button" aria-label="Close menu">
  <svg aria-hidden="true">...</svg>
</button>

When the visible words are "Buy now" and you want more detail, keep those words first:

<a href="/desk" aria-label="Buy now: walnut desk">Buy now</a>

On site builders

Most unnamed controls come from a theme, an app or a widget, so you may not be able to reach the code yourself.

To a developer, say: "Give each control listed in this report an accessible name that includes its visible text."

How to check

Press Rescan on your report after you publish the change. It confirms that a name exists and contains the visible words. Read each name yourself and ask whether it would make sense on its own.