Skip to main content
No Result Found

role-required

Ensure that the roles of interactive elements are not missing or incorrect.

Rule Severity : Serious

Interactive elements should have their roles defined using the role attribute. A proper role helps assistive technologies like screen readers identify the user interactive element properly. When all user interactive elements have a role assigned, users of assistive technologies can interact with your website more easily, and not lose out on important functionality.

For a list of appropriate widgets roles, see ARIA-prescribed widget roles.

Example

In the following example, an interactive element is used but doesn’t define its role.

Incorrect sample - no role defined
Copy icon Copy

The following example fixes this issue by defining the role ‘button’ to the interactive element:

Correct sample with role
Copy icon Copy

How to fix?

Follow these steps to fix any misses in the role-required rule:

  • Ensure that a widget role is declared on the element. Add the appropriate role from ARIA-prescribed widget roles.
  • If the interactive element is made of multiple interactive elements, add a composite role to the element from the composite widgets specified by ARIA.
  • If the interactive element is not supposed to be interacted with, set the role as none or presentation.

Reference

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback

Is this page helping you?

Yes
No

We're sorry to hear that. Please share your feedback so we can do better

Contact our Support team for immediate help while we work on improving our docs.

We're continuously improving our docs. We'd love to know what you liked





Thank you for your valuable feedback!

Talk to an Expert
Download Copy Check Circle