{"id":35942,"date":"2023-10-31T05:15:49","date_gmt":"2023-10-31T10:15:49","guid":{"rendered":"https:\/\/theadminbar.com\/?post_type=accessibility-weekly&p=35942"},"modified":"2024-02-10T06:54:28","modified_gmt":"2024-02-10T12:54:28","slug":"mobile-nav-and-hamburger-menus","status":"publish","type":"accessibility-weekly","link":"https:\/\/theadminbar.com\/accessibility-weekly\/mobile-nav-and-hamburger-menus\/","title":{"rendered":"Mobile Nav and Hamburger Menus"},"content":{"rendered":"\n

When I asked in The Admin Bar Facebook group<\/a> what accessibility questions people have, there were questions about mobile nav and hamburger menu accessibility.<\/p>\n\n\n\n

I\u2019ve previously written about navigation menu accessibility<\/a> in general and accessibility for secondary navigation menus.<\/a> This article is about the additional considerations that need to be made for accessibility in mobile menus.<\/p>\n\n\n\n

No Hamburger Menus on Desktop<\/strong><\/h2>\n\n\n\n

In recent years, I have seen fewer websites designed with mobile menus on desktop. However, there are many themes out there, especially older themes created a few years ago, that aim for a \u201cminimalist\u201d aesthetic and utilize a mobile (a.k.a. a hamburger) menu on desktop.<\/p>\n\n\n\n

There is research going as far back as 2014 that finds that users may have difficulty finding content on websites without a visible navigation bar.<\/a> Though having a collapsed menu on desktop isn\u2019t a Web Content Accessibility Guidelines (WCAG) violation, it\u2019s a design choice that is less user-friendly than a visible menu.<\/p>\n\n\n\n

Compare, for example, this side-by-side of the Visit California website<\/a> from 2016 and now.<\/p>\n\n\n\n

\"Two <\/picture><\/figure>\n\n\n\n

In the 2016 version of the Visit California website (hat tip, Adrian Roselli<\/a>), the header has a Map link, a search icon, and a hamburger menu. Clicking the hamburger menu opens the site navigation in a menu on the right side of the site.<\/p>\n\n\n\n

On the current website, the navigation menu has visible links: Places To Visit, Things To Do, Trip Inspiration, and Road Trips. These links appear to the left of the hamburger icon, which now includes the word \u201cmore\u201d along with the icon.<\/p>\n\n\n\n

If you were planning a visit to California, which nav menu would you find more helpful? Most likely, you\u2019d say the current, visible menu is better because it surfaces key pages.<\/p>\n\n\n\n

Whether you\u2019re designing custom websites or evaluating an existing theme for use as a starter, prioritize making crucial pages visible in the primary navigation and avoid mobile navigation on desktop menus to help people move through the site faster.<\/p>\n\n\n\n

Why Mobile Nav Accessibility<\/strong><\/h2>\n\n\n\n

Wondering why your mobile navigation menu needs to be keyboard accessible if you\u2019re not supposed to show it on desktop or laptop displays?<\/p>\n\n\n\n

Your mobile navigation menu needs to work with a keyboard for two key reasons:<\/p>\n\n\n\n

    \n
  1. People with low vision will zoom websites 200-400% to make the text larger.<\/strong> When websites are zoomed this much, they will adapt the mobile styles, and the mobile menu will be visible on desktop to low-vision users. Some of these users may be unable to use a mouse and will be keyboard-only users.<\/li>\n\n\n\n
  2. Blind people who visit websites don\u2019t only use computers.<\/strong> Many users use a screen reader like VoiceOver on their iPhones to engage with the web. Just as websites need to work on desktop for screen reader users, they also need to work with screen readers on mobile devices, which includes having screen reader-friendly mobile navigation.<\/li>\n<\/ol>\n\n\n\n

    Key Things to Watch Out For<\/strong><\/h2>\n\n\n\n
    \"The <\/picture><\/figure>\n\n\n\n

    Above is a screenshot of the Equalize Digital website<\/a> zoomed to 400% and showing the mobile nav opened on the site. There are three items visible below the logo and button to close the menu; each item has a button with a plus icon next to it, indicating there are sub-items.<\/p>\n\n\n\n

    When assessing this (or any) mobile menu for accessibility, here is what you want to check for:<\/p>\n\n\n\n

      \n
    1. You can tab from the logo to the button that opens the menu.<\/li>\n\n\n\n
    2. The button that opens the menu is an actual button<\/a> and can be triggered with the Enter\/Return key or Space Bar.<\/li>\n\n\n\n
    3. The button that opens and closes the menu needs to function like an accordion with aria-expanded and aria-controls attributes<\/a>.<\/li>\n\n\n\n
    4. The icon on the menu can change (from a hamburger icon to an X as is shown in the example above), but the aria-label or screen reader text on the button should not change. (I.e., it shouldn\u2019t go from \u201cOpen Menu\u201d to \u201cClose Menu.\u201d)<\/li>\n\n\n\n
    5. Once you have opened the menu with a keyboard, hitting the Tab key takes you to the first item in the menu, not the somewhere on the page behind the menu.<\/li>\n\n\n\n
    6. If there are submenus\/dropdowns and the top item is linked, there is a way to go both to the top item link and also to expand the collapsed sub menu (for example, the + buttons in the screenshot above).<\/li>\n\n\n\n
    7. The header is not sticky, so if the user needs to scroll down to access more menu items, they have full use of the window height.<\/li>\n\n\n\n
    8. All items pass color contrast.<\/a><\/li>\n\n\n\n
    9. There\u2019s a visible focus outline<\/a> as each element receives focus.<\/li>\n\n\n\n
    10. All buttons have a reasonable tap-target size that can be tapped easily by people with limited dexterity. The recommended minimum is 44×44 pixels.<\/li>\n\n\n\n
    11. Treat the mobile menu like a popup and add a focus lock<\/a> – don\u2019t allow users to tab past it without closing it.<\/li>\n\n\n\n
    12. Allow the mobile nav to close with the escape key.<\/li>\n\n\n\n
    13. When closing the mobile menu, the user should still be in the header with their focus returned to the button that triggered it, not anywhere else on the page.<\/li>\n<\/ol>\n\n\n\n

      What\u2019s with all the aria-hidden?<\/strong><\/h2>\n\n\n\n

      If you use our WordPress Accessibility Checker plugin<\/a>, you may notice that it flags ARIA hidden warnings<\/a> on the hamburger icon, down carets, and close icons in many themes\u2019s nav menus.<\/p>\n\n\n\n

      As described in the Accessibility Weekly ARIA Hidden<\/a> article, aria-hidden=\u201dtrue\u201d is an HTML attribute that can be added to any element to tell screen readers to skip it and anything contained within it.<\/p>\n\n\n\n

      In many instances, it is correct to hide hamburger and other nav menu icons from screen readers because there is an alternate way of naming the buttons and the image is unnecessary noise to a screen reader user. However, if the theme developer has not provided screen reader text<\/a> or an aria-label on the button, then a possible fix would be not to hide the icon and give it the correct alt text instead.<\/p>\n\n\n\n

      If you encounter alerts or warnings about aria-hidden attributes in an accessibility testing tool, all you need to do is inspect the element on the front end and determine if there\u2019s an accessible name for the button. Here are two good examples from popular themes.<\/p>\n\n\n\n

      Kadence uses the aria-label attribute on the button tag:<\/p>\n\n\n\n

      \"a <\/picture><\/figure>\n\n\n\n

      GeneratePress uses hidden screen reader text within the button tag:<\/p>\n\n\n\n

      \"a <\/picture><\/figure>\n\n\n\n

      If you see one of these two things, you can safely ignore any ARIA hidden warnings for icons in the buttons. If neither are there, then the button may need to be fixed.<\/p>\n\n\n\n

      Testing Mobile Nav Accessibility<\/strong><\/h2>\n\n\n\n

      The best way to tell if your mobile nav menus are accessible is to test them. You can use an automated tool like Accessibility Checker, and you should also manually check for problems.<\/p>\n\n\n\n

      Haven\u2019t tested a mobile nav menu for accessibility? It\u2019s easy! Open the website in any browser, zoom in until you see the mobile nav on your computer, and use your keyboard and a screen reader to check for problems, keeping in mind the \u201cwhat to watch for\u201d list above.<\/p>\n\n\n\n

      Have questions? Comment on this post in the Facebook group.<\/p>\n","protected":false},"featured_media":35947,"template":"","banner":[],"acf":[],"_links":{"self":[{"href":"https:\/\/theadminbar.com\/wp-json\/wp\/v2\/accessibility-weekly\/35942"}],"collection":[{"href":"https:\/\/theadminbar.com\/wp-json\/wp\/v2\/accessibility-weekly"}],"about":[{"href":"https:\/\/theadminbar.com\/wp-json\/wp\/v2\/types\/accessibility-weekly"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/theadminbar.com\/wp-json\/wp\/v2\/media\/35947"}],"wp:attachment":[{"href":"https:\/\/theadminbar.com\/wp-json\/wp\/v2\/media?parent=35942"}],"wp:term":[{"taxonomy":"banner","embeddable":true,"href":"https:\/\/theadminbar.com\/wp-json\/wp\/v2\/banner?post=35942"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}