liveBook · Manning

Accessible name

As explained in Architecting Accessibility

An accessible name is the programmatically determined text label that identifies an interface element to users of assistive technologies.

An icon-only link with no accessible name may be announced simply as “link.” A screen reader user hears that something is clickable but not where it goes. An accessible name supplies the programmatically available label that identifies an element and its purpose. section 5.4

The browser includes an element’s name alongside its role, state, and relationships in the accessibility tree, then exposes that information to assistive technologies. The result depends on the underlying HTML: the browser cannot infer what an unlabeled control was meant to do. section 2.5.3

Name a form field visibly

Give an input a nearby, permanently visible label and associate the two using matching for and id values. A screen reader can then announce “Owner’s name” when the field receives focus. A voice-control user can say “click Owner’s name” to select it. A placeholder is not a substitute for that label. section 6.1.1

<label for="name">Owner’s name</label> #A
<input name="name" id="name" type="text" /> #A

The label’s for value matches the input’s id, connecting visible text to the control. section 6.1.1

Choose the simplest naming approach that fits the element:

  • For an ordinary form control, prefer a visible native label. Use fieldset and legend when related controls need group context. section 6.1.1
  • For an icon-only control without suitable adjacent text, use aria-label. If visible text already provides the name, aria-labelledby can reference it. section 6.1.1
  • For an image-only link, give the image alternative text that states the link’s purpose. If an image and adjacent text lead to the same place, make one link and give the image empty alternative text. section 5.4

NOTE: aria-label and aria-labelledby take precedence over a native form label in the accessibility tree. A field visibly labeled “Payment amount” can be announced only as “Euros” if aria-labelledby points solely to a nearby currency label. Check that the resulting name preserves the control’s purpose. section 6.1.1

TIP: A symbol that communicates information needs more than color or shape alone. A sales-trend symbol, for example, can use an accessible name or visually hidden text to expose its meaning to assistive technologies. section 3.2

Names also help identify larger structures. A form can use aria-labelledby to reference its preceding heading; its individual fields can retain their own visible labels. Keep additional instructions distinct from the name by associating them as descriptions. section 6.1.10 section 6.1.1

How Architecting Accessibility covers it

How deep it goes
Explains naming through the accessibility tree and works through native labels, image links, ARIA alternatives, and naming precedence.
Examples
Contrasts empty icon links with named links and shows a visibly labeled input and a form named by its heading.
What it assumes
Assumes familiarity with HTML elements and attributes while explaining how labels become available to assistive technologies.
What you can do after
Build it from scratch using visible labels and appropriate alternatives, then check that each name communicates its element’s purpose.
How it connects
Connects accessible names to semantic HTML, the accessibility tree, alternative text, visible form labels, and accessible descriptions.

Also explained in

Compare how 2 books explain accessible name →

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.