Controls with accessible names, roles, and states
Basic principle
To be accessible, all interactive controls must clearly communicate their purpose and current status to assistive technologies. This includes providing a programmatically determinable name, role (type of control, such as button, link, or checkbox), and state (e.g., expanded, selected, disabled). These attributes help screen reader users and others understand and interact with controls accurately.
Testing
Tools: browser inspector, tab, enter/return, spacebar, screen reader (preferred)
For each interactive control, check for an accessible name, the correct role and state, and that state changes are announced.
- For each template, make a list or take note of all interactive elements (controls) to test. Look for:
- Links
- Buttons
- Any other advanced controls, such as accordions or tabs.
- Right-click on each control and select Inspect to open the browser dev tools inspector.
- Verify the control has a unique accessible name that clearly describes its purpose. Accessible names may come from:
- Visible text content (e.g., button label)
aria-labeloraria-labelledby- Associated
<label>element for inputs
- If a control has both visible text and
aria-labeloraria-labelledby, ensure that the ARIA text includes the visible text at the beginning of thearia-labeloraria-labelledby. - Verify the control has an appropriate role. For example:
- A button should be
<button>or haverole="button". Buttons perform an action on a page (such as expanding collapsed content or submitting a form), whereas links go somewhere. - A form or search field should be an
<input>,not a<span>or a<div>.
- A button should be
- If any elements have been turned into buttons with
role="button", verify they can be triggered using the spacebar. - If the control changes state dynamically (e.g., opens a panel or reveals content), verify that the initial state and any changes in state (such as from collapsed to expanded) are communicated programmatically using ARIA attributes.
- Tab to the control with the
tabkey, then pressspacebarorenter/returnto activate it. Watch the value of the relevant ARIA attribute in the inspector to observe changes, such asaria-expandedtoggling fromfalsetotrue.
- Tab to the control with the
- If there are buttons that are disabled, such as a comment form that disables the submit button until required fields are completed, verify that the button has a
disabledattribute. - (Rare) If the theme includes a tabs component, verify the tab controls are programmatically defined and associated with the tab panel. See link in WCAG resources for tab pattern expectations.
- Preferred: Use a screen reader (e.g., VoiceOver, NVDA) to confirm the name, role, and state are announced correctly.
- Repeat this process for all controls in your list.
- After testing the desktop view, switch into responsive mode or zoom your browser at least 200% and test responsive toggles (e.g., hamburger menu toggles) in the same way.
WCAG resources
- Understanding: Non-text Content
- Understanding: Info and Relationships
- Understanding: Name, Role, Value
- Understanding: Label in Name
- Tab Pattern Expectations
WP Accessibility Knowledge Base