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

<nav role="navigation" aria-label="Main menu">
<ul>
<li>
<button aria-expanded="false">Who we are and what we do</button>
<ul class="non-visible">
[…]
</ul>
</li>
<li>
<button aria-expanded="true">Institutional relations</button>
<ul class="visible">
<li><a href="…">Institutional relations</a></li>
<li><a href="…">Events</a></li>
[…]
</ul>
</li>
<li><a href="…">International cooperation</a></li>
[…]
</ul>
</nav>

ARIA roles, states and properties

  • The <nav role="navigation"> tag must be used to structure the menu.
  • The aria-label attribute 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-expanded attribute 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

Your email address will not be published. Required fields are marked *

Updates

20 August 2024
ARIA reference added and sample code modified.
27 October 2025
Minor update.

Back to top