Skip to content

Articles · Good practices

Visible label and accessible name: when aria-label contradicts the button

A button shows “Cancel” but is called “Close the window” for screen readers. Voice control users can no longer refer to it by the word they read, and a blind person being guided cannot find it. What the RGAA and WCAG require.

By

· Published on

A person controls their computer by voice, with Dragon or their system’s voice control. They read “Cancel” on a button and say that word to activate it. The software looks for an element whose name matches the spoken words. But the developer added aria-label="Close the window": for the software, this button is called “Close the window”, and “Cancel” does not identify it.

The same gap gets in the way of a blind person who is being helped. The person guiding them looks at the screen and says “click Cancel”. Their screen reader, however, announces “Close the window”. They look for a Cancel button in the list of buttons, cannot find it, and neither of them understands why.

Two texts for the same button

The visible label is the text displayed on screen. The accessible name is the one the browser passes on to assistive technologies. Without an ARIA attribute, the two are the same. With an aria-label or an aria-labelledby, the accessible name replaces the displayed text, and the two can differ.

What the RGAA requires

RGAA 4.1.2 sets the same requirement in several tests: the accessible name must contain at least the visible label. Test 7.1.3 does the same for user interface components generated by a script.

  • For links, test 6.1.5: « Pour chaque lien ayant un intitulé visible, le nom accessible du lien contient-il au moins l’intitulé visible (hors cas particuliers) ? » (For each link that has a visible label, does the link’s accessible name contain at least the visible label, except in particular cases?)
  • For form fields, test 11.2.5: « Chaque champ de formulaire ayant un intitulé visible vérifie-t-il ces conditions (hors cas particuliers) ? » (Does each form field that has a visible label meet these conditions, except in particular cases?)
  • For buttons, test 11.9.2: « Chaque bouton affichant un intitulé visible vérifie-t-il ces conditions (hors cas particuliers) ? » (Does each button displaying a visible label meet these conditions, except in particular cases?)

The framework provides for particular cases: punctuation and capital letters can be ignored, and a symbol such as “>” must be named by its function, “Next” for example, rather than read as it is.

What WCAG requires

Success criterion 2.5.3 Label in Name (Level A) of WCAG 2.2 requires the accessible name of a user interface component to contain the text of its visible label. The W3C recommends placing this text at the start of the accessible name: “Order now, Arco lamp” rather than “Arco lamp, order now”.

The RGAA repeats this advice in the technical note of criterion 6.1: “Arco lamp: order now” is still valid, but “Order Arco lamp now” is not, because it splits the visible label.

Three common cases

  • <button aria-label="Close the window">Cancel</button>: non-compliant, “Cancel” is not in the accessible name.
  • <a href="/offre" aria-label="Read more of the article on the summer offer">Read more</a>: compliant, the name starts with the visible label.
  • A field whose French label displays « Courriel » (email) and which carries aria-label="Adresse e-mail" (email address): non-compliant, « Courriel » does not appear in the accessible name.

Our advice

Before adding an aria-label to an element that already displays text, ask yourself whether it is useful. Most of the time, a more precise visible text solves the problem for everyone. If extra information is needed, keep the visible label at the start, word for word.

Sources

Leave a Reply

Every comment is reviewed before it is published. Your email address will not be published. Fields marked with an asterisk (*) are required. See the privacy policy.

Read also