Drop-down menu
Summary
Principle

A drop-down menu is usually a series of “buttons” displayed side by side. A sub-menu is displayed below the activated button.
This code is based on the “Disclosure Navigation Menu” design pattern found in the ARIA Authoring Practices Guide (APG) of the W3C.
The source code and implementation examples for this component are available in this guide.
Core HTML base
ARIA roles, states and properties
- The
<nav role="navigation">tag must be used to structure the menu. - The
aria-labelattribute must be included in the same<nav role="navigation">tag and set with the name of the corresponding menu. - Nested
<ul>and<li>tags must be used to structure the first-level buttons and sub-menu links. - Each first-level button must be marked with a
<button>tag. - The
aria-expandedattribute must be included in each first-level button. Its value must be dynamically set according to the status of the associated sub-menu:aria-expanded="false"when the associated sub-menu is collapsed.aria-expanded="true"when the associated sub-menu is expanded.
Keyboard interactions
Enter and Spacebar
When the keyboard focus is positioned on a button, alternately displays/hides the sub-menu associated with that button.
Esc
If a dropdown is open, closes it and sets focus on the button that controls that dropdown.
Note
The sub-menus that are not displayed must be hidden using display: none; or visibility: hidden;.
Comments
Leave a Reply
Updates
- 20 August 2024
- ARIA reference added and sample code modified.
- 27 October 2025
- Minor update.