How to make a dropdown menu keyboard accessible
A dropdown menu is keyboard accessible when someone can reach it with Tab, open it with Enter or Space, move through every item and close it with Escape. If your menu only opens when a mouse hovers over it, keyboard users cannot reach the pages inside it.
Many websites have a main menu where sub pages appear when you point at a heading such as Services or Shop. For people who navigate with a keyboard, a switch device or a screen reader, that hover effect often does nothing, so the sub pages might as well not exist. The fix is usually small, and you can test it in two minutes without any tools.
What the problem looks like
The typical signs are easy to spot once you know them:
- You press Tab and the focus skips straight past the sub menu items to the next link or the page content.
- The menu opens on hover but nothing happens when you tab to the parent item and press Enter or Space.
- The sub menu opens, but you cannot see which item is focused because there is no visible outline or highlight.
- The menu opens and then you cannot close it, or it stays open over the page content.
- A screen reader announces the parent item as plain text and never says that it has a sub menu.
The cause is almost always the same: the menu was built to react to the mouse (:hover) only, or the parent item is a plain div or span instead of a real link or button.
Why it matters
Some visitors cannot use a mouse at all: people with motor disabilities, people with a broken wrist, power users who prefer the keyboard, and screen reader users. If your key pages sit inside a dropdown they cannot open, you lose those customers and enquiries. Keyboard operation is also a basic legal and standards expectation. It is covered by WCAG success criterion 2.1.1 Keyboard (Level A), and related rules include 2.4.7 Focus Visible, 4.1.2 Name, Role, Value and 1.4.13 Content on Hover or Focus. WCAG 2.2 also adds 2.4.11 Focus Not Obscured (Minimum), which matters when a sticky header covers the focused item.
There is a side benefit for search too. Sub pages that are only reachable through a broken menu depend on other links to be found, and a clear, working menu helps everyone understand your site structure.
How to check your site for free
Start with the keyboard test. Put your mouse aside and open your home page.
- Press
Tabrepeatedly. Can you see a clear outline or highlight on each item as you go? - When you reach a menu item that has a sub menu, press
EnterorSpace. Does the sub menu open? - Press
Tabagain. Does focus move into the sub menu items in a sensible order? - Press
Esc. Does the sub menu close and does focus return to the parent item? - Press
Shift+Tabto go backwards. Does it follow the same path? - Repeat on your phone width layout if you have a keyboard connected, or check the mobile menu button the same way.
Then run an automated check for extra evidence. The free tools Lighthouse (built into Chrome DevTools), WAVE and the axe DevTools browser extension will flag missing roles, names and focus problems. They cannot prove a menu works by keyboard, so treat them as a second opinion after your own test.
How to fix it in general
The most reliable pattern is called a disclosure menu. Each parent item is a real link plus a real button that shows and hides the sub menu. Native buttons already work with Enter and Space and are announced properly by screen readers.
<nav aria-label="Main">
<ul>
<li>
<a href="/services/">Services</a>
<button type="button" aria-expanded="false" aria-controls="sub-services">
<span class="visually-hidden">Show Services pages</span>
</button>
<ul id="sub-services" hidden>
<li><a href="/services/design/">Design</a></li>
<li><a href="/services/hosting/">Hosting</a></li>
</ul>
</li>
</ul>
</nav>
Then a few lines of script toggle it:
const btn = document.querySelector('[aria-controls=sub-services]');
const menu = document.getElementById('sub-services');
btn.addEventListener('click', () => {
const open = btn.getAttribute('aria-expanded') === 'true';
btn.setAttribute('aria-expanded', String(!open));
menu.hidden = open;
});
menu.addEventListener('keydown', (e) => {
if (e.key === 'Escape') {
btn.setAttribute('aria-expanded', 'false');
menu.hidden = true;
btn.focus();
}
});
Key points to keep in mind:
- Use real
aandbuttonelements. If your parent item is a clickablediv, see div used as a button. - Keep
aria-expandedin sync with what is visible, so screen readers say "collapsed" or "expanded". - Do not hide sub menus with
display: noneand then expect:focus-withinto open them. Items that are not displayed cannot receive focus. - Keep hover as an extra, not the only way. Add
:focus-visiblestyles so the focused item is obvious. - Make sure the open menu is not trapped or hidden under a sticky header. If focus gets stuck, see keyboard traps.
- Keep the DOM order the same as the visual order, otherwise you will create an illogical tab order.
- Arrow key navigation is optional for a site menu. Tab, Enter, Space and Escape are what matter most.
Fixing it on common platforms
Where the setting lives depends on your theme or template version, so look for the idea rather than an exact label.
- WordPress: menus are built in Appearance, then Menus, or in the Site Editor with the Navigation block. Many modern themes handle keyboard use well. Older themes and some mega menu add ons do not, so test, then check the theme or plugin settings and update it. If it still fails, ask the theme author or a developer.
- Shopify: the menu comes from your theme (Online Store, Themes). Recent official themes usually work by keyboard. Heavily customised or older themes often do not, and the fix is in the theme code.
- Wix, Squarespace: you cannot edit the underlying code of the standard menu. Test it, try a simpler menu style (for example a click to open style or a plain list of links), and contact support if the standard menu fails.
- Webflow: the built in Dropdown element is designed for keyboard use, but custom interactions that open menus on hover only can break it. Check any custom interaction you added.
- Elementor: the Nav Menu widget has options for how the sub menu is triggered (hover or click) and the mobile layout. Try the click option and test again.
- Drupal: it depends on your theme and menu module, so test and review the theme templates.
If the platform cannot be fixed, the simplest workaround is to make the parent items normal links to landing pages that list the sub pages.
How to confirm the fix worked
Repeat the six step keyboard test on the home page and on at least one inner page, in a desktop and a narrow layout. Then run Lighthouse, WAVE or axe again to be sure no new errors were added. If you can, also try a screen reader such as NVDA (Windows, free) or VoiceOver (built into Mac and iPhone) and listen for the menu being announced as a button with an expanded or collapsed state.
How to stop it coming back
Menus tend to break when a theme is updated, a plugin is added or a designer changes the header. Add the keyboard test to your checklist whenever the navigation changes, and ask developers to use real links and buttons. Re-check after theme or plugin updates.
The SiteMonday week 7 accessibility audit checks the site against WCAG 2.2 and ends with a written report and a ranked fix list, so you can see menu problems alongside other accessibility issues. Fixing them is still up to you or your developer.
Step by step for your platform
- Dropdown menu not keyboard accessible on WordPress
- Dropdown menu not keyboard accessible on Shopify
- Dropdown menu not keyboard accessible on Wix
- Dropdown menu not keyboard accessible on Squarespace
- Dropdown menu not keyboard accessible on Webflow
- Dropdown menu not keyboard accessible on Elementor
- Dropdown menu not keyboard accessible on Drupal
Questions
Does a dropdown menu have to open with the Enter key?
Yes, a keyboard user must be able to open it without a mouse. Enter and Space are the usual keys, and using a real button gives you both automatically.
Is hover only a dropdown ever acceptable?
Not as the only way to open it. Hover can stay as an extra, but the same items must also open from focus or a keypress.
Do I need arrow key navigation in my menu?
No. For a normal website navigation menu, Tab, Shift+Tab, Enter, Space and Escape are enough. Arrow keys are an optional extra.
Why does my sub menu items get skipped when I press Tab?
Usually they are hidden with `display: none` or are not real links, so they cannot receive focus. The menu needs a real button or trigger that shows them first.
Which WCAG rules apply to dropdown menus?
Mainly 2.1.1 Keyboard, 2.4.7 Focus Visible, 4.1.2 Name, Role, Value, 1.4.13 Content on Hover or Focus, and 2.4.11 Focus Not Obscured (Minimum) in WCAG 2.2.
Can I fix this myself if I am not a developer?
Sometimes. Changing the menu style or a theme setting may be enough, but custom code problems usually need a developer.