WCAG 2.1 · Level A · Robust

WCAG 4.1.2 — Name, Role, Value, explained with examples

For every UI component, the name, role, and state (and any value where applicable) must be programmatically determinable. A custom toggle that looks like a switch but is built from <div>s is invisible to assistive tech. WCAG 4.1.2 is the bridge between custom UI and the accessibility tree.

Number
4.1.2
Level
A
Principle
Robust
Guideline
4.1 Compatible

Why this criterion exists

A custom toggle that looks like a switch but is built from <div>s is invisible to assistive tech. WCAG 4.1.2 is the bridge between custom UI and the accessibility tree.

If you only remember one thing: for every ui component, the name, role, and state (and any value where applicable) must be programmatically determinable. Everything else on this page is detail.

Who feels it when this fails

Accessibility criteria sometimes feel abstract until you see who pays the cost when a site ignores them. Name, Role, Value affects:

  • Screen reader users

  • Voice control users

  • Switch device users

How sites typically fail it

These are the patterns we see week after week. None are intentional — they are accidents of how teams build interfaces under deadline. Knowing the failure modes is the fastest path to writing them out of your component library.

  • <div role="button"> without aria-label

  • Toggle state not reflected in aria-pressed

  • Custom dropdown without combobox role

How to test for it

  • Inspect components with the browser accessibility tree (Chrome DevTools → Accessibility).

Automated scanners catch this criterion most of the time, but never all of the time. Manual testing with the keyboard and a screen reader closes the gap.

A code fix you can copy

<button> gives role and keyboard handling. aria-pressed conveys the on/off state to assistive tech.

The problem

HTML
<div class="toggle-on" onclick="toggle()"></div>

The fix

HTML
<button type="button" aria-pressed="true" onclick="toggle()">
  Notifications
</button>

<button> gives role and keyboard handling. aria-pressed conveys the on/off state to assistive tech.

Other Robust criteria

Find every accessibility issue on your site in 60 seconds.

Free public scan. No card. AI-generated fixes for every issue we find.