Skip to content
easeweb
Search topics

Navigation menus built as an app's menu bar

A site's header is marked up with role="menubar": its submenu buttons are menu items but its plain links are not, so a screen reader counts only some of them.

WCAG 2.2
SC 1.3.1A
Required by
Section 508 · EN 301 549 (EU)
Broken <div role="menubar">
The accessibility problem illustrated: No vision:Is that the whole menu?
01

The problem

Screen reader users are told the menu has fewer items than it shows, and the links left out of it are reached only by Tab, outside the menu

02

Try it

Move through the menu with Tab, then with the arrow keys, and listen to the count

Tab stops on Home, Shop and Journal, never on Help, and on Shop the panel says “1 of 2”: the menu bar counts only Shop and Help. From Shop, Right Arrow jumps to Help, past Journal. Then apply a fix and count again.

Broken Can you fix this?

BrokenA menu bar with links beside its menu items

Screen reader says:

(Tab to the menu)

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Make the navigation links, with a button for each submenu

Before
BrokenA menu bar with links beside its menu items
<header>  <div class="menu" role="menubar">    <a href="/" aria-current="page">Home</a>    <button type="button" role="menuitem" aria-haspopup="menu" aria-expanded="false" aria-controls="shop-menu" tabindex="0">Shop</button>    <a href="/journal">Journal</a>    <button type="button" role="menuitem" aria-haspopup="menu" aria-expanded="false" aria-controls="help-menu" tabindex="-1">Help</button>  </div>  <div id="shop-menu" role="menu" aria-label="Shop" hidden>    <a href="/shop/lamps" role="menuitem" tabindex="-1">Lamps</a>    <a href="/shop/chairs" role="menuitem" tabindex="-1">Chairs</a>    <a href="/shop/rugs" role="menuitem" tabindex="-1">Rugs</a>  </div>  <div id="help-menu" role="menu" aria-label="Help" hidden>    …  </div></header>
What is wrong3 points
  • Home and Journal are links inside a menu bar, which can own only menu items, so they are not its items. A screen reader counts two items, Shop "1 of 2" and Help "2 of 2".
  • Right Arrow moves between Shop and Help only, so it skips Journal.
  • Tab stops on Home, Shop and Journal, and never on Help, which has tabindex="-1" until Right Arrow reaches it.
After

A nav with links and submenu buttons

<header>  <nav aria-label="Main">    <ul class="menu">      <li>        <a href="/" aria-current="page">Home</a>      </li>      <li class="has-sub">        <button type="button" aria-expanded="false" aria-controls="shop-menu">Shop</button>        <ul id="shop-menu" tabindex="-1" hidden>          <li>            <a href="/shop/lamps">Lamps</a>          </li>          <li>            <a href="/shop/chairs">Chairs</a>          </li>          <li>            <a href="/shop/rugs">Rugs</a>          </li>        </ul>      </li>      <li>        <a href="/journal">Journal</a>      </li>      <li class="has-sub">        <button type="button" aria-expanded="false" aria-controls="help-menu">Help</button>        <ul id="help-menu" tabindex="-1" hidden>          …        </ul>      </li>    </ul>  </nav></header>
How it is fixed5 steps
  1. Replace the menu bar with a nav named Main, holding a list with one li per item. A screen reader announces the navigation and a list of four items, and every item is in it.
  2. Keep Home and Journal as plain links, and make Shop and Help plain buttons: no role, no aria-haspopup, no tabindex. Each is its own Tab stop, in the order shown, and is read as what it is.
  3. Put each submenu's list straight after its button, with aria-expanded on the button kept in step with hidden on the list, and aria-controls pointing at it. Tab goes from the button into the open list.
  4. Close an open list on Escape, with focus back on its button, and when focus leaves its item. Put tabindex="-1" on the list so a click inside it doesn't count as leaving.
  5. Remove the menu bar's key handling. Tab moves through the navigation; nothing needs the arrow keys.

This fixes the Before and passes 1.3.1: the list holds every item, and nothing is left outside it. Hover-only dropdowns, or ones that never say they are open explains the button, its state and the two ways it closes in detail.

Why this fix: Use native HTML first

Easily confused
04

Verify the fix

4 checks, no mouse.

Test with: Screen reader, Keyboard

0 of 4 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 component changes.

Limits

This guide is about the roles a site's navigation is given. A submenu that opens only on hover, or a button that never says whether its list is open, is covered in hover-only dropdowns, or ones that never say they are open. 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.

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