WCAG Encyclopedia

4.1.2 · RobustLevel A

Name, Role, Value

Every control has to expose three things programmatically: what it is called, what kind of thing it is, and what state it is in — and it has to update as that state changes. This is the criterion that custom components fail.

Principle
Robust
Guideline
4.1
Level
A
In WCAG since
2.0
Number
4.1.2

Broken, then fixed

The same interface twice: first with the mistake, then with the smallest change that fixes it.

Broken: A custom toggle that exposes nothing.
Email notificationsannounced as"" — group

Two divs and a click handler. No name, no role, no state — a screen reader user cannot tell it exists, let alone whether it is on.

Fixed: Name, role, and state, all present and live.
Email notificationsannounced as"Email notifications, switch, on"

A native <input type="checkbox" role="switch"> gets all three for nothing and updates itself. Where a custom element is unavoidable, role, aria-checked, and a real label have to be written and kept in sync by hand.

What changed in the code

The fix as a diff: removed lines are marked with a minus, added lines with a plus.

Markup diff — settings.html
removed: <div class="toggle" tabindex="0" onclick="toggle()"></div>
removed: <div class="toggle-text">Email notifications</div>
added: <label>
added:   <input type="checkbox" role="switch" checked>
added:   Email notifications
added: </label>

The state changes are the part hand-rolled components forget. A native control cannot fall out of sync with itself.

Watch it happen

This demo plays the failure out over time. It is silent and captioned, and you can pause or scrub at any point.

Screen readersilent

CaptionA toolbar of icon-only buttons.
0:00 / 0:18CC onSilent · looping

How to test

Check your own interface against 4.1.2, one step at a time.

  1. List every control on the page that is not a native HTML control: anything built from div or span elements that acts as a button, toggle, tab, menu or slider.
  2. Open the accessibility inspector in your browser (the Accessibility pane in Chrome or Edge DevTools, or the Accessibility tab in Firefox) and select each control. Check that it has a name, and that the name says what the control does.
  3. Read the role the inspector shows for each control. It has to say what the control is, such as button, checkbox, switch, tab or slider. A role of generic, group or none means the control exposes no role.
  4. Operate each control with the keyboard while the inspector is open. Check that its state changes with it: a toggle turns checked, a menu button turns expanded, a slider reports its new value.
  5. Turn on a screen reader (NVDA on Windows, VoiceOver on a Mac) and move to each control. Listen for its name, its role and its state, then change it and listen for the new state.

Common questions

Do native HTML controls pass 4.1.2 on their own?

Yes, once they have a name. A native button, link, checkbox or select exposes its role and state and keeps them up to date by itself. Most failures are custom controls, or native ones whose role ARIA has overridden.

Is aria-label enough to pass 4.1.2?

No. aria-label gives a control a name, but it still needs a role, and a state if it has one. A div with aria-label and a click handler is still announced as nothing a person can operate.

Does 4.1.2 check that the name matches the visible label?

No. 4.1.2 asks only that the control has a name. 2.5.3 Label in Name asks that the name contains the words of the visible label, so a person using voice control can say what they see.

Try it yourself

A lab is a small working piece of interface that you change yourself. Read its steps, use the controls under it, and watch the verdict line at the bottom: it says whether the criterion passes or fails as you go. Reset puts it back.

Try it: build the toggle

How to use this lab

  1. Goal. Build an “Email notifications” toggle that a screen reader can name, describe and read.
  2. The controls. The options under “Role: the element” pick what the toggle is built from. The options under “Name: where it comes from” give it a name or not, and those under “State: the attribute” pick None, aria-pressed or aria-checked. The Switched on tick box turns the toggle on or off, and the markup and log show the result.
  3. Try this. The lab starts as A plain div with no name and no state. Choose A native <button>, The text inside the control and aria-pressed. Then choose A div with role="switch" and compare aria-pressed with aria-checked.
  4. What it means. When the log gives a role, a name and an on or off state, 4.1.2 passes: aria-pressed suits a button, and aria-checked suits a switch. Leave any one out, or pair the wrong state with the role, and 4.1.2 fails, because screen reader and voice control users can’t tell what the control is, what it’s called or whether it’s on. The verdict line under the lab says which.
Role: the element
Name: where it comes from
State: the attribute

The markup

<div>…</div>

Screen reader says

    4.1.2 fails

    Also in guideline 4.1

    Criteria in the same guideline often fail together.