Skip to main content
Raasta
MinorBest practicearia-allowed-role

Role not allowed on this element

Giving an element a role that clashes with what it already is, such as role="button" on a heading or role="navigation" on a list, mixes up how it is announced and how it behaves. Remove the role, or wrap the content in the element that matches what it does.

Who it hurts

Screen reader users, who lose the original meaning (a heading stops being a heading), and keyboard users if the new role promises behaviour that isn’t there.

Often seen on accordions, where the heading itself is made clickable, and on menus. A <button> inside the heading keeps both meanings.

How to fix it

Pick your stack. Review every change before you ship it.

Before

<ul role="navigation">
  <li><a href="/shop">Shop</a></li>
</ul>

After

<nav aria-label="Main">
  <ul>
    <li><a href="/shop">Shop</a></li>
  </ul>
</nav>

Check it by hand too

Check headings, lists and links still read as headings, lists and links in your screen reader’s headings and landmarks lists.

Automated checks find a large share of accessibility problems, but not all of them. Passing this check does not on its own make a page compliant.