Skip to content
easeweb
Search topics

Dropdown menus that open only on hover

The submenu under a top-level item is shown by a :hover rule alone, so Tab skips every page in it.

WCAG 2.2
SC 2.1.1ASC 4.1.2A
Required by
Section 508 · EN 301 549 (EU)
Broken .has-sub:hover > ul { display: block; }
The accessibility problem illustrated: The pages drop down under the mouse. Tab never opens them.
01

The problem

Keyboard and screen reader users can't reach the pages listed under a top-level menu item.

02

Try it

Reach Lamps using only Tab and Enter.

Hover over Products with a mouse to see the list, then try the keyboard. With the list open, try Escape, and keep tabbing past About: does the list cover the next link?

Broken Can you fix this?

Screen reader says:

(Tab to the menu)

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Give every submenu a way to open from the keyboard, and say whether it is open.

  1. 1Every submenu opens without a mouse: from a button, a summary or keyboard focus.
  2. 2A control that opens a submenu says whether it is open.
  3. 3An open submenu that covers the page closes with Escape and never hides the control that has focus.
Before A submenu shown on hover
<nav aria-label="Main">  <ul class="menu">    <li><a href="/">Home</a></li>    <li class="has-sub">      <a href="/products">Products</a>      <ul>        <li><a href="/products/lamps">Lamps</a></li>        <li><a href="/products/chairs">Chairs</a></li>        <li><a href="/products/rugs">Rugs</a></li>      </ul>    </li>    <li><a href="/about">About</a></li>  </ul></nav>
After

A button that opens the submenu

<nav aria-label="Main">  <ul class="menu">    <li><a href="/">Home</a></li>    <li class="has-sub">      <button type="button" aria-expanded="false" aria-controls="sub-products">Products</button>      <ul id="sub-products" tabindex="-1" hidden>        <li><a href="/products">All products</a></li>        <li><a href="/products/lamps">Lamps</a></li>        <li><a href="/products/chairs">Chairs</a></li>        <li><a href="/products/rugs">Rugs</a></li>      </ul>    </li>    <li><a href="/about">About</a></li>  </ul></nav>

Why this fix: Use native HTML first

Fixing this with an AI coding assistant? Get this guide as Markdown

04

Verify the fix

5 checks, no mouse.

Test with: Keyboard, Screen reader, Zoom, Touch

0 of 5 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat after the shared header or menu component changes.

Limits

This is a starting pattern for a site's navigation menu, not for application menus with commands, which follow the ARIA menu pattern and its arrow keys. The script is a minimal sketch without animation, hover opening or nested levels. Test the complete journey, including your narrow-screen menu, with your target assistive technology.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

Keep this fixed as your code changes.

Turn guides like this into rules your coding agents and CI follow, then have the result retested with a keyboard and screen readers.

How retests work