[role] values are not valid
How to fix the aria-roles accessibility rule. ARIA.
The message you saw
Lighthouse runs axe-core inside it, so both are the same check, and the fix below works whichever tool showed you the message.
What it means
The role attribute tells assistive technology what an element is, and it only accepts names from the ARIA standard, such as button, dialog, tab or navigation. This message means an element’s role isn’t one of them, so browsers ignore it and the element is treated as whatever it would be without it.
Typical causes are typos (role="buton"), invented names (role="btn", role="nav", role="popup"), and “abstract” roles. The standard uses abstract roles like widget, landmark, input, section, structure, command, range and window to organise itself; they are not meant for web pages, and axe flags them too.
Who is affected
The role attribute uses a name that isn't a real ARIA role (often a typo or an invented name), so browsers ignore it and the element isn't announced as intended.
Screen-reader users don’t get the role you intended. A <div role="btn"> is announced as plain text, not a button, so people don’t know it can be pressed.
How to find it
- Run the checker on the page: the report shows the role value it didn’t recognise.
- Search your code for
role=and compare each value against the WAI-ARIA list of roles.
How to fix it
- Correct the spelling, or replace the invented name with the real one:
role="button",role="navigation",role="dialog". - Better still, use the native element:
<button>,<nav>,<dialog>. Then you don’t need a role at all. - Replace abstract roles with a concrete one that describes the element, or remove them.
- If the element is just for layout, remove the role. Don’t add
role="layout"or similar: there is no such role.
Example
Before
<div role="btn" onclick="save()">Save</div>After
<button type="button" onclick="save()">Save</button>Common mistakes
- The role attribute can list several roles as fallbacks (
role="switch checkbox"); browsers use the first one they know. axe only fails it when none of them are valid. - Roles are lowercase in the standard. Write them that way.
WCAG success criteria
When this rule fails, the page fails:
- 4.1.2 Name, Role, Value (Level A, WCAG 2.0, 2.1, 2.2)
Check your fix
Scan a web page and the report lists every element that fails this rule, with screenshots outlining where they are, the code, and a selector you can paste into your browser’s developer tools. Scan again after your change: when the rule no longer appears under the problems, the fix worked.
An automated pass means this rule found nothing wrong. It doesn’t prove the page is accessible: some of what WCAG asks for needs a person to check, and the report’s manual checklist lists those steps.
Related fix guides
- Deprecated ARIA roles were used
- Uses ARIA roles on incompatible elements
[role]s do not have all required[aria-*]attributes- Buttons do not have an accessible name
More detail
- Deque University’s reference for aria-roles (the makers of axe-core, the engine our scanner uses)
- W3C’s Understanding 4.1.2
- All fix guides