Open Dropdown Menus With the Keyboard
Shows a classic theme's dropdown submenu while a keyboard user tabs through it, for themes whose dropdowns only open on mouse hover.
Opens WPIDE on
Code
.main-navigation .menu-item-has-children:focus-within > .sub-menu,
#site-navigation .menu-item-has-children:focus-within > .sub-menu,
nav .menu-item-has-children:focus-within > .sub-menu {
display: block;
left: auto;
opacity: 1;
visibility: visible;
clip: auto;
pointer-events: auto;
}
Notes
Adjust the selector if your theme's menu is not inside .main-navigation, #site-navigation or nav.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.