How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (2024)

To make the most of limited page space, web designers frequently employ drop-down menus. A drop-down menu is a list of links that is hidden initially and revealed when the user interacts with the main navigation or parent menu. These links descend vertically, or 'drop down.'

How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (1)

Typically the hidden menu, or submenu, is shown on a hover event, when a user moves the mouse over a parent item. The submenu remains visible until the user disengages with the menu. This lets designers place more links on a page without cluttering the display.

In the example below, a drop-down menu labeled 'Documentation' opens a submenu containing links to different documentation resources.

How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (3)

Image Source

A perfect solution, right? Well, not quite yet. Drop-down menus are convenient for most of us. But, if these menus fail to account for web accessibility, they become more of an obstacle than a convenience for some.

Accessible drop-down menus are important because they help people with disabilities browse your site. More specifically, they assist those experiencing visual, motor, and cognitive limitations.

If your drop-down menus are not accessible, these users may miss out on key sections of your website, and it may take them a long time to find the information they need. As a result, your menus will detract from their user experience and users may not make a return visit (and, of course, it's not fair to them).

To prevent this from happening, this post will explain the fundamentals of drop-down menu accessibility that website administrators and developers should know when creating them. Later on, we'll discuss how these concepts can be applied to fly-out menus. Let's get started.

How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (4)

Website Accessibility Checklist

This checklist will help you make the following more accessible on your website:

  • Web Pages
  • Navigation
  • Video & Media
  • And More!
Learn more

    Download Free

    All fields are required.

    How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (5)

    You're all set!

    Click this link to access this resource at any time.

    Download Now

    How Might People With Disabilities Use Drop-Down Menus?

    It's important to understand how site visitors with disabilities use your navigation so you know how to address accessibility problems.

    Someone living with multiple sclerosis, for example, may have muscle spasms, tremors, or muscle weakness. These symptoms make it difficult to hold and control a computer mouse, so your menus should be accessible by a keyboard in addition to a mouse cursor. When the user presses an appropriate key, the drop-down menu becomes visible, just as it would for someone using a mouse.

    If you hover over a link in a menu with a mouse, you also expect to see a change in background color or border color. Someone using a keyboard needs the same visual cue so they know which link they have currently selected —this is called the focus style. A keyboard user can't reference the mouse pointer to tell where they are on the page, so a clear focus style is crucial.

    We also need to take into account common user interface practices that not everyone takes for granted. For example, users with cognitive disabilities may not realize that some drop-down menu items are hidden. This can be a problem on mobile websites too, where navigation is often toggled by a hamburger icon.

    Lastly, the larger the menu, the more potential for poor accessibility. Mega menus, like the one pictured below, are a type of drop-down menu that displays submenu links in a large box. Mega menus may have images or video as part of the menu, and often have links headed by topic.

    As the name implies, mega menus contain a lot of information, so they must be organized intuitively. A poorly organized mega menu is less usable overall if it fails to guide users to their destination, and this is especially true for users with cognitive disabilities.

    How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (6)

    With these considerations in mind, let’s now unpack how drop-downs can be made accessible from the ground up.

    How to Make a Web-Accessible Drop-Down Menu

    The first step to building an accessible drop-down menu is to plan your site structure. That is, figure out your top-level pages that will appear in the main navigation, then determine which of those need child pages.

    Below is an example of the basic structure for navigation with drop-down menus. In the example, the “Services” page has four child pages, and the “Blog” page has three child pages. So, there will be two submenus that would drop down, triggered by an interaction with the “Services” and “Blog” elements.

    How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (7)

    Child pages can also have their own children. For example, you might have two child pages for the “Marketing” category on your blog, like “Content marketing” and “Email marketing”. This type of navigation is called a two-level submenu.

    How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (8)

    Most content management systems have navigation settings that allow you to set child pages. Usually, you can configure your navigation links through drag-and-drop.

    However, too many levels of a drop-down menu can make your navigation difficult to use. For example, someone with weakness in the hands may not have sufficient motor control to move a mouse in the right areas to open all submenus. Therefore, it’s always best to keep your submenus as simple as you can.

    With your menu structure planned, you can start to implement a menu that’s accessible for all. To do this, you may need a developer's help, as accessible drop-down menus need to be coded correctly to meet the needs of different user groups.

    Fortunately, the W3C Web Accessibility Initiative (WAI) has shared standards and best practices for drop-downs. Here’s what they recommend:

    Accessible Drop-Down Menus for Mouse Users

    Visitors that can use a mouse but don't have fine motor control require drop-down menus to remain visible for long enough to use. If a drop-down menu appears on mouse hover but the user doesn't have a steady hand, the menu will disappear too quickly when they accidentally disengage with it. This is an inaccessible menu.

    The solution is to implement a time delay from when the mouse leaves the menu area to when the menu closes. In the example below, a time delay of a second has been applied to the drop-down menu when the mouse moves away. This way, the user can right their cursor in time.

    How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (9)

    Image Source

    Here’s the code to produce this type of menu:

    <nav aria-label="Main Navigation"> <ul> <li><a href="…">Home</a></li> <li><a href="…">Shop</a></li> <li class="has-submenu"> <a href="…" aria-haspopup="true" aria-expanded="false">Space Bears</a> <ul> <li><a href="…">Space Bear 6</a></li> <li><a href="…">Space Bear 6 Plus</a></li> </ul> </li> <li><a href="…">Mars Cars</a></li> <li><a href="…">Contact</a></li> </ul></nav>nav > ul li ul { display: none;}nav > ul li:hover ul { display: block;} var menuItems = document.querySelectorAll("li.has-submenu");Array.prototype.forEach.call(menuItems, function (el, i) { el.addEventListener("mouseover", function (event) { this.className = "has-submenu open"; clearTimeout(timer); }); el.addEventListener("mouseout", function (event) { timer = setTimeout(function (event) { document.querySelector(".has-submenu.open").className = "has-submenu"; }, 1000); });});

    Source

    Accessible Drop-Down Menus for Keyboard Users

    Users who are reliant on a keyboard must be ableto navigate your drop-down menus via the tabkey and the enterkey. If they can't see the drop-downs when navigating a page, they won't know what links exist and where they lead.

    According to the WAI, "Submenus should not open when using the tabkey to navigate through the menu, as keyboard users would then have to step through all submenu items to get to the next top-level item." It also recommends two approaches to get around this:

    Using the Parent Menu Item as Toggle

    In this example, the “Space Bears” link has submenu items. This link doesn't go to a location in itself —it acts as a trigger to open the drop-down menu.

    How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (10)

    Image Source

    The user can press tabfive times to cycle through the menu in sequence up to the final menu item, “Contact”. As they press tab, the keyboard user can easily see which link they have selected because the white foreground and navy background colors of the navigation are inverted, and the link is also underlined.

    How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (11)

    Image Source

    If a user presses enteron a parent menu item with a submenu, the drop-down menu becomes visible.

    How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (12)

    Image Source

    See Also
    ARIA

    Pressing tabagain highlights the first link in the drop-down menu.

    How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (13)

    Image Source

    A user can then press enterto visit the highlighted link, or tabto move to the next link in the drop-down menu.

    Here’s the JavaScript to enable this functionality:

    var menuItems = document.querySelectorAll("li.has-submenu");Array.prototype.forEach.call(menuItems, function (el, i) { el.querySelector("a").addEventListener("click", function (event) { if (this.parentNode.className == "has-submenu") { this.parentNode.className = "has-submenu open"; this.setAttribute("aria-expanded", "true"); } else { this.parentNode.className = "has-submenu"; this.setAttribute("aria-expanded", "false"); } event.preventDefault(); return false; });});

    Source

    One disadvantage with this method is that it might not be obvious to a sighted keyboard user that a drop-down menu is present. Someone could use the tabkey to go all the way to Contact without discovering the Space Bears drop-down menu.

    Using the Button as Toggle

    In this example, the top-level menu item of “Space Bears” is linked to another page, so it can't toggle the drop-down menu. Instead, the arrow icon to the right of the link signals that a drop-down menu is present. The button also has some hidden text for screen reader users to tell those people that the button toggles a drop-down menu.

    How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (14)

    Image Source

    When the toggle button is selected with the keyboard, it takes on a white highlight.

    How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (15)

    Image Source

    When a visitor triggers the button by pressing enter, the drop-down menu opens.

    How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (16)

    Image Source

    The drop-down menu behaves as in the previous example — pressing tabselects the first link.

    How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (17)

    Image Source

    This implementation requires a bit more code, which W3C provides:

    var menuItems = document.querySelectorAll("li.has-submenu");Array.prototype.forEach.call(menuItems, function (el, i) { var activatingA = el.querySelector("a"); var btn = '"; activatingA.insertAdjacentHTML("afterend", btn); el.querySelector("button").addEventListener("click", function (event) { if (this.parentNode.className == "has-submenu") { this.parentNode.className = "has-submenu open"; this.parentNode.querySelector("a").setAttribute("aria-expanded", "true"); this.parentNode .querySelector("button") .setAttribute("aria-expanded", "true"); } else { this.parentNode.className = "has-submenu"; this.parentNode.querySelector("a").setAttribute("aria-expanded", "false"); this.parentNode .querySelector("button") .setAttribute("aria-expanded", "false"); } event.preventDefault(); });});

    Source

    Accessible Drop-Down Menus for Blind Users

    Finally, blind users who use a screen reader need the menu coded as an unordered list of links so that they can tell how many links are in the main navigation or each drop-down menu. They also need to know which link is the current page they're on.

    Now, let's take a look at another type of accessible drop-down menu that combines some of the features we've seen in the previous examples.

    How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (18)

    Website Accessibility Checklist

    This checklist will help you make the following more accessible on your website:

    • Web Pages
    • Navigation
    • Video & Media
    • And More!
    Learn more

      Download Free

      All fields are required.

      How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (19)

      You're all set!

      Click this link to access this resource at any time.

      Download Now

      Superfish Plugin for Creating Accessible Drop-Down Menus

      Superfish is a widely used JavaScript plugin that supports accessible drop-down menus. It works on touch devices as well as desktop and laptop computers. Superfish is available for developers to download and use in web development projects. The plugin is also incorporated into some themes and templates for popular content management systems.

      For users who have difficulty controlling a mouse, Superfish adds a delay when the mouse moves off the drop-down menu before it closes. This delay is set to 0.8 seconds by default and can be increased if required.

      Superfish also offers full support for keyboard users — arrows show the user where there are submenus.

      Superfish navigation can be horizontal, vertical, or nav-bar. You can also build multi-level drop-down menus using Superfish, or use it to create mega menus. Here's an example of a Superfish navigation bar menu:

      How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (20)

      Image Source

      No matter which type of Superfish menu you choose, your users interact with it in the same way, by using the tabkey to navigate through the menu items. Pressing tabautomatically opens up any drop-down menu on the page.

      The main downside of Superfish's navigation is that a user has to tabthrough all the menu items in a drop-down menu before moving to the next top-level item. If your drop-down menus have many links, that's a lot of keystrokes. So, it's important to plan your main navigation well and trim the unnecessary links.

      Accessible Fly-Out Menus

      Depending on who you talk to, the term "drop-down menu" can mean different things. In this article, we’ve considered drop-down menus to be any type of website navigation with multiple levels that descend vertically. However, there’s another type of drop-down menu that you’ve probably seen, fly-outmenus.

      Like a regular drop-down menu, a fly-out menu is a hidden submenu that is revealed on interaction with the navigation. Unlike regular drop-downs, however, the hidden content "flies-out" horizontally.

      A fly-out menu can have multiple levels to it, and is often better at implying page hierarchies in this way. Here's an example of a two-level fly-out menu:

      How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (21)

      Image Source

      Despite the difference in presentation, our accessibility principles for drop-downs also apply to fly-out menus: The structure of links should be clear and intuitive, options should be navigable by the mouse as well as the keyboard, and the menu should be coded in such a way that is legiblefor screen readers. Also, consider setting a time delay before submenu items disappear.

      Note that drop-down menus and fly-out menus can also be combined. In the example below, the “Depth” element has a drop-down menu showing “Level 01”. “Level 01” contains a fly-out menu for “Level 02”, which in turn reveals “Level 03” as a fly-out.

      How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (22)

      Image Source

      Making Menus Accessible

      As we’ve seen, to make accessible drop-down menus you need to keep in mind the needs of different disabled user groups.

      Making your menus simple and logical, allowing extra time for them to respond to mouse movements, using the correct code for screen reader users, and ensuring your menus can be operated with the keyboard all play their part.

      By using accessible drop-down menus, your website will be easier to navigate, and no one will be excluded.

      Topics: Web Accessibility

      How to Create Drop-Down and Fly-Out Menus That Are Web-Accessible (2024)
      Top Articles
      Renew an SSL/TLS certificate
      Best Way to Invest £100K - How to Invest £100,000 for High Returns
      Zabor Funeral Home Inc
      Sound Of Freedom Showtimes Near Governor's Crossing Stadium 14
      La connexion à Mon Compte
      Crocodile Tears - Quest
      Plus Portals Stscg
      Arrests reported by Yuba County Sheriff
      What is IXL and How Does it Work?
      Craigslist Heavy Equipment Knoxville Tennessee
      Scholarships | New Mexico State University
      Jc Post News
      I Wanna Dance with Somebody : séances à Paris et en Île-de-France - L'Officiel des spectacles
      Available Training - Acadis® Portal
      Kürtçe Doğum Günü Sözleri
      Powerball winning numbers for Saturday, Sept. 14. Check tickets for $152 million drawing
      Convert 2024.33 Usd
      Inter-Tech IM-2 Expander/SAMA IM01 Pro
      Ruben van Bommel: diepgang en doelgerichtheid als wapens, maar (nog) te weinig rendement
      Bridge.trihealth
      Earl David Worden Military Service
      ELT Concourse Delta: preparing for Module Two
      Mychart Anmed Health Login
      라이키 유출
      Ppm Claims Amynta
      Hannaford To-Go: Grocery Curbside Pickup
      Bethel Eportal
      [PDF] PDF - Education Update - Free Download PDF
      Valic Eremit
      How do you get noble pursuit?
      Umn Biology
      Taylored Services Hardeeville Sc
      897 W Valley Blvd
      Productos para el Cuidado del Cabello Después de un Alisado: Tips y Consejos
      Edict Of Force Poe
      Snohomish Hairmasters
      Muziq Najm
      Wsbtv Fish And Game Report
      Htb Forums
      Wait List Texas Roadhouse
      Weather Underground Corvallis
      Oppenheimer Showtimes Near B&B Theatres Liberty Cinema 12
      Miami Vice turns 40: A look back at the iconic series
      11 Best Hotels in Cologne (Köln), Germany in 2024 - My Germany Vacation
      At Home Hourly Pay
      Yourcuteelena
      Ucla Basketball Bruinzone
      Reli Stocktwits
      Poster & 1600 Autocollants créatifs | Activité facile et ludique | Poppik Stickers
      Osrs Vorkath Combat Achievements
      Strange World Showtimes Near Century Federal Way
      OSF OnCall Urgent Care treats minor illnesses and injuries
      Latest Posts
      Article information

      Author: Rev. Leonie Wyman

      Last Updated:

      Views: 5921

      Rating: 4.9 / 5 (79 voted)

      Reviews: 86% of readers found this page helpful

      Author information

      Name: Rev. Leonie Wyman

      Birthday: 1993-07-01

      Address: Suite 763 6272 Lang Bypass, New Xochitlport, VT 72704-3308

      Phone: +22014484519944

      Job: Banking Officer

      Hobby: Sailing, Gaming, Basketball, Calligraphy, Mycology, Astronomy, Juggling

      Introduction: My name is Rev. Leonie Wyman, I am a colorful, tasty, splendid, fair, witty, gorgeous, splendid person who loves writing and wants to share my knowledge and understanding with you.