liveBook · Manning

Aria-labelledby

As explained in Architecting Accessibility

aria-labelledby is an ARIA attribute that supplies an accessible name by referencing one or more visible labeling elements.

A “Read more...” link in a carousel may make sense beside its heading but lose that context when a screen reader presents links out of context. Give the link a descriptive name. If its visible text cannot be changed, aria-labelledby can reference a visible heading in the same carousel section. section 5.4

aria-labelledby supplies an accessible name by referencing the IDs of elements containing the naming text. When the name needs text from several visible elements, provide their IDs as a space-separated list. section 6.1.1

Choose the simplest labeling approach that fits:

  • For an ordinary form control, use a visible <label> associated through for and id. For related controls, use <fieldset> and <legend> to provide group context. section 6.1.1
  • For a custom control that cannot use <label> but has suitable visible text nearby, reference that text with aria-labelledby. section 6.1.1
  • For a form with a preceding heading, aria-labelledby can reference that heading to name the form. section 6.1.10
<label for="amount">Payment amount</label> #A
<span id="currency">Euros</span> #B
<input id="amount" aria-labelledby="currency"> #C

Watch for an incomplete name: referencing only “Euros” makes the input’s accessible name “Euros,” rather than “Payment amount Euros.” aria-labelledby takes precedence over the native label, so check the complete name before adding it. section 6.1.1

How Architecting Accessibility covers it

How deep it goes
Explains when to reference one or several elements and warns that the resulting name can override a native label; stops short of accessibility-tree internals.
Examples
Uses a carousel’s “Read more...” link, a payment field named only “Euros,” and a form named by its heading.
What it assumes
Assumes familiarity with HTML links and form controls while explaining when native labels should take priority.
What you can do after
Operate/configure it by referencing visible text with element IDs and checking that the resulting accessible name remains complete.
How it connects
Connects accessible names to descriptive link text, HTML labels, form headings, aria-label, and screen readers.

Also explained in

Compare how 3 books explain aria-labelledby →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Architecting Accessibility. The section links point to the parts of the book it draws on.