Skip to content
easeweb
Search topics

Hover-only dropdowns, or ones that never say they are open

A submenu is shown by a :hover rule alone, so Tab skips every page in it, or it opens from a button that never says whether the list is open.

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: Motor:How do I get to Lamps?
01

The problem

Keyboard users can't reach the pages listed under a top-level menu item, and screen reader users can't tell that they are there or whether the list is open

02

Try it

Reach Lamps using only Tab and Enter

  • Broken 1: hover over Products with a mouse to see the list, then try the keyboard. Tab goes from Products to About, and the panel says only "Products, link", with nothing about a list.

  • Broken 2: Products is a button. Press Enter and the list opens, and Tab reaches Lamps, but the panel says "Products, button" before and after, never whether the list is open.

  • Apply the fix. With the list open, try Escape, and keep tabbing past About: does the list cover the next link?

Broken Can you fix this?

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Open each submenu by keyboard, and say whether it is open

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>
What is wrong2 points
  • Tab never reaches the three category pages: it goes from Products straight to About, because their links are display: none until a pointer rests on Products.
  • A screen reader says only "Products, link", with nothing about a submenu, because nothing in the markup says Products has one.
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>
How it is fixed7 steps
  1. Make Products a native button, which opens and closes with Enter and Space.
  2. Give it aria-expanded, kept in step with hidden, so a screen reader says "Products, button, collapsed", then "expanded".
  3. Tie the list to the button with aria-controls. The list follows the button in the markup, so Tab goes straight from the button into the open list, and hidden keeps the links out of the Tab order while it is closed.
  4. Close the list on Escape, and put focus back on Products.
  5. Close it when focus moves out of the item, with Tab, Shift + Tab or a click elsewhere, without moving focus anywhere, so an open list never covers the next thing people tab to.
  6. Put tabindex="-1" on the list, so a click inside it keeps focus within the item, and that click doesn't count as leaving.
  7. The button no longer goes to the overview page, so move that page into the list as "All products".

This fixes both Befores and passes 2.1.1 and 4.1.2. Against the second Before, the button and its click toggle stay; what this adds is aria-expanded, aria-controls and the two ways to close, Escape and focus leaving.

Why this fix: Use native HTML first

Easily confused
04

Design ideas

A dropdown can open for the keyboard too

Four ways to draw the same shop header. Point at Products, then put the mouse aside and Tab through each: press Enter on a button, Escape with a list or panel open, and keep tabbing on to Spring sale. Three open for everyone or have nothing to open; in the last, only a mouse can open the list.

In the design file

  • Decide whether Products goes to its own page or opens a list. If it opens a list, put an “All products” link inside it.
  • If an arrow button next to a link opens the list, give it a name, such as “Products pages”.
  • Draw focus on the menu button and on each link in the open list.
  • Draw the phone menu, with the lists stacked under one Menu button that pushes the page down when it opens.

Passes

  • Products link with its own chevron button Products stays a link to its overview, and a round 32px chevron button beside it, #1a1a1a on #f0ede7 at 14.90:1, opens the pages in a floating card and turns over while it is open. The overview stays one click away, at the cost of one more Tab stop and a name for the button, such as “Products pages”.

    Rule of thumb: Use native HTML first

  • This week’s offer: Spring sale

    A Menu button that opens a panel Every page sits in one panel under a dark Menu pill, white on #1a1a1a at 17.40:1, the products as small pills. The panel pushes the offer down instead of covering it, so it can stay open while you tab on; Escape closes it.
  • No dropdown: the pages as a row of pills Lamps, Chairs and Rugs sit under the header all the time, so there is nothing to open, hover or find. It costs a row of height and three more Tab stops, so it suits a short menu.

Fails

05

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.

How screen readers handle aria-expanded

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; a sidebar whose sections hold further sections is covered in tree views keyboards can't open and screen readers flatten. 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.

EaseWeb service

Fixed it? Keep it from coming back.

I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.

See the service