Q10 of 24 · Accessibility
What is an accessible name and how is it computed for interactive elements?
AccessibilityMidaccessibilityaccessible-nameariawcaglabelstesting
Short answer
Short answer: An accessible name is what assistive technology announces as the label for an element. The browser computes it via the accessible name computation algorithm, which checks author-provided sources first (aria-labelledby, then aria-label, then the native labelling mechanism) before falling back to element content.
Detail
The accessible name and description computation (ANDC) algorithm runs in priority order:
- aria-labelledby (highest priority): the element's name comes from the text of another element(s) referenced by ID. Used for complex labels that reference multiple text nodes.
- aria-label: an explicit string provided directly on the element. Overrides everything below it.
- Native labelling mechanism: varies by element type. For
<input>, it's the associated<label>element (viafor/idor wrapping). For<button>, it's the button's text content. For<img>, it's thealtattribute. - Element content (lowest): for some roles (button, link), the text content of the element itself serves as the name.
- No name: if all of the above are absent, the element has no accessible name — a failure.
Common failures:
- Icon-only buttons with no label: a
<button>containing only an SVG icon has no accessible name unless the icon has a title oraria-labelis added to the button. - Placeholder as the only label:
placeholdertext is not part of the accessible name computation for inputs — it disappears when the user starts typing and is never a label substitute. - Unlabelled inputs:
<input type="email">with no<label>, noaria-label, and noaria-labelledbyhas no accessible name.
Testing: inspect the Accessibility pane in DevTools. The "Name" field shows the computed accessible name. If it's empty for an interactive element, that's a bug.
// WHAT INTERVIEWERS LOOK FOR
States the priority order: aria-labelledby > aria-label > native mechanism > content. Can give at least two examples of common accessible name failures. Knows to inspect in DevTools.
// COMMON PITFALL
Thinking placeholder text functions as an accessible label. It does not — it disappears during input, it has poor colour contrast, and it is explicitly excluded from the name computation algorithm.