Accessible Name

Accessibilityintermediate

// Definition

The label a screen reader announces for an element — computed from a priority order of sources: `aria-labelledby`, then `aria-label`, then native content (a button's text, an input's `<label>`), then `title`. Two buttons that look identical can have different (or missing) accessible names, which is exactly what assistive-tech users experience.

// Why it matters

A control with no accessible name is invisible to screen-reader users — an icon-only button announces as just "button". QA cares because this is one of the most common, most impactful accessibility failures, and it's testable: you can assert an element's computed accessible name automatically, no manual pass required.

// How to test

// Assert the computed accessible name (axe + role queries)
cy.findByRole('button', { name: /close dialog/i }).should('exist')
// icon-only button must STILL have a name:
cy.get('[data-cy=icon-close]')
  .should('have.attr', 'aria-label').and('not.be.empty')

// Common mistakes

  • Icon-only buttons/links with no aria-label (announce as just "button")
  • Assuming a visible label is the accessible name (it depends on the priority order)
  • aria-label overriding useful visible text, so name ≠ what's shown

// Related terms