Uses ARIA roles on incompatible elements

How to fix the aria-allowed-role accessibility rule. ARIA. A best practice, not a WCAG requirement.

The message you saw

Lighthouse and PageSpeed Insights
Uses ARIA roles on incompatible elements
axe-core, axe DevTools and this checker
ARIA role should be appropriate for the element (rule aria-allowed-role)

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

HTML elements come with their own meaning, and the HTML standard lists which ARIA roles each element may take instead. This message means an element has a role that isn’t on its list, for example a heading turned into a button, a text field turned into a button, or an image that has alt text but is marked as decorative.

The role overrides what the element is, but not how it behaves. The browser still treats an <h2 role="button"> as a heading for some purposes and a button for others, and the result differs between browsers and screen readers.

Who is affected

The role conflicts with the HTML element it's on (for example a heading made into a button), so the element's real meaning is lost or behaves inconsistently.

Screen-reader users can lose the element’s real meaning (a heading that disappears from the list of headings) or get a role whose keyboard behaviour isn’t there. It is a best practice, not a WCAG failure by itself, but it often comes with real problems.

How to find it

  1. Run the checker with “Also show best-practice suggestions” ticked: the report shows the element and the role that doesn’t fit.
  2. Search your code for role= on headings, <input>s, <img>s with alt text, and <li>s.

How to fix it

  1. Use the element that matches what the thing does. A control that does something is a <button>; a heading that opens a section can contain a button: <h2><button aria-expanded="false">…</button></h2>.
  2. If the role was added for styling or by habit, remove it.
  3. For images: role="presentation" with real alt text contradicts itself. If the image is decorative use alt=""; if it carries meaning, keep the alt and drop the role.

Examples

A heading that opens a section (accordion)

Before

<h2 role="button" tabindex="0">Delivery</h2>

After

<h2><button type="button" aria-expanded="false">Delivery</button></h2>

An image marked decorative but with alt text

Before

<img src="team.jpg" alt="Our support team" role="presentation">

After

<img src="team.jpg" alt="Our support team">

Common mistakes

WCAG success criteria

None. This is a best practice: fixing it helps people using assistive technology, but it doesn’t affect WCAG conformance. Our scanner only reports it if you tick “Also show best-practice suggestions”.

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

More detail