Skip to main content
No Result Found

role-required-menu

Make sure that the role attribute of an interactive menu element is not incorrect or missing.

Rule Severity : Critical

Description

Ensure that each individual menu item has the correct role (eg: menuitem), and the parent container has the appropriate role (eg: menubar).

You can refer to this guide by ARIA to create accessible menu and menubar elements.

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

Why is it important?

The WAI-ARIA specification provides an informative description of each role, how it relates to other roles, and the states and properties for each role. When rich internet applications define new user interface widgets, exposing the roles enables users to understand the widget and how to interact with it.

How to fix?

Define a menu element using the menuitem role or another appropriate role. If the element is composed of multiple interactive elements, add a composite role like menubar to the element from the set of ARIA-prescribed widget roles. If the menu element is not supposed to be interacted with, set the role as none or presentation.

Example

The following is an example of a menu without a defined role.

HTML
Copy icon Copy

The following example shows the menu with the composite role menubar and individual item roles defined as menuitem.

HTML
Copy icon Copy

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