216digital.
Web Accessibility

Phase 1
Web Remediation for Lawsuit Settlement & Prevention


Phase 2
Real-World Accessibility


a11y.Radar
Ongoing Monitoring and Maintenance


Consultation & Training

Is Your Website Vulnerable to Frivolous Lawsuits?
Get a Free Web Accessibility Audit to Learn Where You Stand
Find Out Today!

Web Design & Development

Marketing

PPC Management
Google & Social Media Ads


Professional SEO
Increase Organic Search Strength

Interested in Marketing?
Speak to an Expert about marketing opportunities for your brand to cultivate support and growth online.
Contact Us

About

Blog

Contact Us
  • Web Accessibility: Making Drop-Down Menus User-Friendly

    Drop-down menus are a staple in website navigation, offering a compact way to organize and access multiple links. But while they streamline user experience, they can also create significant barriers if not designed with accessibility in mind. For users who rely on screen readers, keyboard navigation, or other assistive technologies, a poorly implemented menu can turn a simple browsing experience into a frustrating ordeal.

    This article will guide website owners, developers, and content creators on how to create accessible drop-down menus that enhance usability for all users. We’ll cover foundational accessibility principles, best coding practices, and testing methods to ensure your menus are inclusive and user-friendly.

    Foundational Accessibility Principles for Drop-Down Menus

    To build accessible drop-down menus, start by understanding core web accessibility principles. Here are the three most critical aspects:

    1. Use Semantic HTML

    Semantic HTML ensures that content is meaningful and properly interpreted by assistive technologies. Instead of using <div> or <span> elements for interactive components, use appropriate HTML elements like:

    • <nav> for navigation sections
    • <ul> and <li> for menu structures
    • <button> to toggle drop-down visibility

    For example:

    <nav>
      <button aria-haspopup="true" aria-expanded="false" id="menuButton">Menu</button>
      <ul id="menu" hidden>
        <li><a href="#">Home</a></li>
        <li><a href="#">About</a></li>
        <li><a href="#">Services</a></li>
        <li><a href="#">Contact</a></li>
      </ul>
    </nav>

    2. Ensure Keyboard Navigation

    Users who navigate via keyboard should be able to open, close, and move through the menu using the Tab and arrow keys. Ensure the following behaviors:

    • The menu should open with Enter or Space when focused on the toggle button.
    • The Esc key should close the menu.
    • Arrow keys should allow navigation within the menu items.

    3. Use ARIA Roles and Attributes Wisely

    ARIA (Accessible Rich Internet Applications) attributes help convey additional information to screen readers. However, improper use can create confusion. Apply ARIA roles correctly:

    • aria-haspopup="true" indicates that a button controls a drop-down menu.
    • aria-expanded="false" updates dynamically when the menu is opened or closed.
    • role="menu" and role="menuitem" clarify the structure.

    Example implementation:

    <button aria-haspopup="true" aria-expanded="false" id="menuButton">Menu</button>
    <ul id="menu" role="menu" hidden>
      <li role="menuitem"><a href="#">Home</a></li>
      <li role="menuitem"><a href="#">About</a></li>
      <li role="menuitem"><a href="#">Services</a></li>
    </ul>

    Structuring Accessible Drop-Down Menus

    Now that we’ve covered the principles, let’s implement an accessible drop-down menu using HTML, CSS, and JavaScript.

    1. Toggling Visibility

    A menu should only be visible when needed. Use JavaScript to control visibility:

    const menuButton = document.getElementById('menuButton');
    const menu = document.getElementById('menu');
    menuButton.addEventListener('click', () => {
      const expanded = menuButton.getAttribute('aria-expanded') === 'true';
      menuButton.setAttribute('aria-expanded', !expanded);
      menu.hidden = expanded;
    });

    2. Managing Focus for Keyboard Users

    When a menu opens, focus should shift inside it. When it closes, focus should return to the toggle button:

    toggle button:
    menuButton.addEventListener('click', () => {
      menu.hidden = !menu.hidden;
      menu.hidden ? menuButton.focus() : menu.querySelector('a').focus();
    });

    3. Enabling Smooth Keyboard Interactions

    To navigate the menu with arrow keys, use this approach:

    menu.addEventListener('keydown', (event) => {
      const items = [...menu.querySelectorAll('a')];
      let index = items.indexOf(document.activeElement);
      
      if (event.key === 'ArrowDown') {
        event.preventDefault();
        index = (index + 1) % items.length;
        items[index].focus();
      } else if (event.key === 'ArrowUp') {
        event.preventDefault();
        index = (index - 1 + items.length) % items.length;
        items[index].focus();
      } else if (event.key === 'Escape') {
        menu.hidden = true;
        menuButton.focus();
      }
    });

    Testing Your Drop-Down Menus for Accessibility

    1. Screen Reader Testing

    Use a screen reader like NVDA (Windows), VoiceOver (Mac), or JAWS to ensure:

    • Menus are announced properly.
    • aria-expanded updates correctly.
    • Navigation follows expected patterns.

    2. Keyboard Testing

    Try navigating your menu using only the keyboard. Ensure:

    • Tab reaches the menu.
    • Enter or Space opens the menu.
    • Arrow keys move between items.
    • Esc closes the menu.

    3. Contrast and Readability

    Ensure proper color contrast between text and background. Use tools like the WebAIM Contrast Checker to verify compliance with WCAG 2.1 standards.

    Best Practices for Creating Intuitive Menus

    • Keep It Simple: Avoid deep nesting that makes menus cumbersome.
    • Ensure Mobile Friendliness: Use larger touch targets for better usability.
    • Avoid Hover-Only Menus: They exclude keyboard users and some assistive technology users.
    • Provide Visual Indicators: Show clear changes when menus expand or collapse.

    Conclusion

    By using semantic HTML, managing focus properly, implementing ARIA roles correctly, and rigorously testing your menus, you can ensure they work for all users, regardless of ability.

    Accessible drop-down menus not only improve usability but also make your site more welcoming to all visitors. Implement these best practices today and make your navigation barrier-free!

    If you’re ready to take the next step toward digital inclusion, reach out to 216digital to schedule an ADA briefing. We’ll help you assess your website, develop a tailored plan, and guide you through the process of building an online presence that works for everyone. Don’t wait—contact us today and let’s make the internet a more accessible place together.

    Greg McNeil

    January 24, 2025
    How-to Guides
    Accessibility, drop-down menus, How-to, WCAG, Web Accessibility, web developers, web development
216digital Scanning Tool

Audit Your Website for Free

Find Out if Your Website is WCAG & ADA Compliant













    216digital Logo

    Our team is full of expert professionals in Web Accessibility Remediation, eCommerce Design & Development, and Marketing – ready to help you reach your goals and thrive in a competitive marketplace. 

    216 Digital, Inc. BBB Business Review

    Get in Touch

    2208 E Enterprise Pkwy
    Twinsburg, OH 44087
    216.505.4400
    info@216digital.com

    Support

    Support Desk
    Acceptable Use Policy
    Accessibility Policy
    Privacy Policy

    Web Accessibility

    Settlement & Risk Mitigation
    WCAG 2.1/2.2 AA Compliance
    Monitoring Service by a11y.Radar

    Development & Marketing

    eCommerce Development
    PPC Marketing
    Professional SEO

    About

    About Us
    Contact

    Copyright 2024 216digital. All Rights Reserved.