{"id":438461,"date":"2026-02-17T09:51:26","date_gmt":"2026-02-17T09:51:26","guid":{"rendered":"https:\/\/www.megamenu.com\/?post_type=ht_kb&#038;p=438461"},"modified":"2026-03-02T10:48:24","modified_gmt":"2026-03-02T10:48:24","slug":"aria-haspopup","status":"publish","type":"ht_kb","link":"https:\/\/www.megamenu.com\/documentation\/aria-haspopup\/","title":{"rendered":"Max Mega Menu and the aria-haspopup attribute"},"content":{"rendered":"<article>\n<blockquote><p><strong>TL;DR:<\/strong> Automated accessibility tools often flag missing <span class=\"lang:default decode:true crayon-inline \">aria-haspopup<\/span>\u00a0\u00a0attributes because they assume all menus should behave like &#8220;Desktop Applications.&#8221; However, Max Mega Menu follows the <a href=\"https:\/\/www.w3.org\/WAI\/ARIA\/apg\/patterns\/disclosure\/examples\/disclosure-navigation\/\"><strong>W3C Disclosure Pattern<\/strong><\/a>. We use <span class=\"lang:default decode:true crayon-inline \">aria-expanded<\/span> , which provides a better experience for screen reader users and avoids confusing navigation &#8220;modes.&#8221;<\/p><\/blockquote>\n<p>If you\u2019ve recently run an accessibility audit or used an automated checker, you might have seen a suggestion to add the <span class=\"lang:default decode:true crayon-inline\">aria-haspopup<\/span> attribute to your menu items.<\/p>\n<p>Adding the <span class=\"lang:default decode:true crayon-inline \">aria-haspopup<\/span>\u00a0 attribute to Max Mega Menu would be a trivial change to the code, so why don&#8217;t we do it? We intentionally omit the <span class=\"lang:default decode:true crayon-inline \">aria-haspopup<\/span>\u00a0 attribute to ensure your site remains accessible to screen reader users. Here is why.<\/p>\n<hr \/>\n<h3>1. Following W3C&#8217;s lead<\/h3>\n<p>The\u00a0<b>World Wide Web Consortium<\/b> (W3C) develops standards and guidelines to help everyone build and enjoy a web based on the principles of accessibility, internationalisation, privacy and security.<\/p>\n<p>The <a href=\"https:\/\/w3.org\">w3.org<\/a> homepage itself uses a mega menu, and does <strong>not<\/strong>\u00a0use the <span class=\"lang:default decode:true crayon-inline \">aria-haspopup<\/span>\u00a0 attribute:<\/p>\n<p><a href=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2026\/02\/w3-haspopup-scaled.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-438508\" src=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2026\/02\/w3-haspopup-scaled.png\" alt=\"\" width=\"2560\" height=\"1678\" srcset=\"https:\/\/www.megamenu.com\/wp-content\/uploads\/2026\/02\/w3-haspopup-scaled.png 2560w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2026\/02\/w3-haspopup-300x197.png 300w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2026\/02\/w3-haspopup-1024x671.png 1024w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2026\/02\/w3-haspopup-768x503.png 768w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2026\/02\/w3-haspopup-50x33.png 50w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2026\/02\/w3-haspopup-1536x1007.png 1536w, https:\/\/www.megamenu.com\/wp-content\/uploads\/2026\/02\/w3-haspopup-2048x1342.png 2048w\" sizes=\"auto, (max-width: 2560px) 100vw, 2560px\" \/><\/a><\/p>\n<p>According to the W3C, most website navigations should follow the <a href=\"https:\/\/www.w3.org\/WAI\/ARIA\/apg\/patterns\/disclosure\/examples\/disclosure-navigation\/\">Disclosure Pattern:<\/a><\/p>\n<blockquote><p>A pattern more suited for typical site navigation with expandable groups of links is the\u00a0<strong>Disclosure Pattern<\/strong>.<br \/>\n&#8212; <a href=\"https:\/\/www.w3.org\/WAI\/ARIA\/apg\/patterns\/menubar\/examples\/menubar-navigation\/\">https:\/\/www.w3.org\/WAI\/ARIA\/apg\/patterns\/menubar\/examples\/menubar-navigation\/<\/a><\/p><\/blockquote>\n<p>The W3C notes that the alternative &#8220;<a href=\"https:\/\/www.w3.org\/WAI\/ARIA\/apg\/patterns\/menubar\/examples\/menubar-navigation\/\">Menubar<\/a>&#8221; pattern (which <em>does<\/em> require the <span class=\"lang:default decode:true crayon-inline\">aria-haspopup<\/span>\u00a0 attribute) is intended for application-like interfaces (think Google Docs or online versions of desktop applications) and can actually make standard website navigation more difficult for screen reader users by forcing them into a specific &#8220;Application Mode.&#8221;<\/p>\n<p>Max Mega Menu follows the disclosure pattern, with some enhancements.<\/p>\n<h3>2. <code>aria-expanded<\/code> vs. <code>aria-haspopup<\/code>: What&#8217;s the difference?<\/h3>\n<p>By using <span class=\"lang:default decode:true crayon-inline \">aria-expanded<\/span>\u00a0, Max Mega Menu tells the user exactly what is happening: they are toggling the visibility of a sub menu. When <span class=\"lang:default decode:true crayon-inline\">aria-haspopup<\/span>\u00a0is used incorrectly on a standard link, a screen reader may expect a complex desktop-style menu where the user must use arrow keys to move around, which can lead to users getting &#8220;stuck&#8221; in the menu.<\/p>\n<p>The core of the confusion often lies in these two attributes. While they might seem similar, they tell a screen reader user very different stories:<\/p>\n<table style=\"width: 100%; border-collapse: collapse; margin: 20px 0; text-align: left;\">\n<thead>\n<tr style=\"background-color: #f8f9fa;\">\n<th style=\"padding: 12px; border: 1px solid #ddd;\">Attribute<\/th>\n<th style=\"padding: 12px; border: 1px solid #ddd;\">The Message Sent to Users<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"padding: 12px; border: 1px solid #ddd;\"><code>aria-expanded<\/code><\/td>\n<td style=\"padding: 12px; border: 1px solid #ddd;\"><em>&#8220;This button controls a section of content that is currently hidden or visible.&#8221;<\/em><\/td>\n<\/tr>\n<tr>\n<td style=\"padding: 12px; border: 1px solid #ddd;\"><code>aria-haspopup<\/code><\/td>\n<td style=\"padding: 12px; border: 1px solid #ddd;\"><em>&#8220;This button triggers a temporary overlay, like a context menu or a dialog box.&#8221;<\/em><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>3. We Prioritise the &#8220;Disclosure&#8221; Pattern<\/h3>\n<p>By following the <a href=\"https:\/\/www.w3.org\/WAI\/ARIA\/apg\/patterns\/disclosure\/examples\/disclosure-navigation\/\">Disclosure Pattern<\/a> (and the <a href=\"https:\/\/www.w3.org\/WAI\/ARIA\/apg\/patterns\/disclosure\/examples\/disclosure-navigation\/#javascriptandcsssourcecode\">example code given<\/a>, which <strong>includes<\/strong> the <span class=\"lang:default decode:true crayon-inline \">aria-expanded<\/span>\u00a0 attribute and <strong>omits<\/strong> the <span class=\"lang:default decode:true crayon-inline \">aria-haspopup<\/span>\u00a0 attribute), we ensure:<\/p>\n<ul>\n<li>Adherence to w3c guidelines.<\/li>\n<li>Users can tab through items naturally without being forced into &#8220;arrow-key&#8221; navigation.<\/li>\n<li>Users hear &#8220;Expanded&#8221; or &#8220;Collapsed,&#8221; which is the most reliable way to communicate state across different browsers and screen readers.<\/li>\n<\/ul>\n<hr \/>\n<h3>How to Add <code>aria-haspopup<\/code><\/h3>\n<p>If you understand the implications and still wish to add the attribute, you can use the built-in WordPress <span class=\"lang:default decode:true crayon-inline \">nav_menu_link_attributes<\/span>\u00a0 filter. Adding this snippet to your theme&#8217;s <span class=\"lang:default decode:true crayon-inline \">functions.php<\/span>\u00a0\u00a0file will inject the attribute into your menu links.<\/p>\n<pre style=\"background: #f4f4f4; padding: 15px; border-radius: 5px; overflow-x: auto;\"><code>\/**\r\n * Add aria-haspopup to Max Mega Menu items for specific audit compliance.\r\n * Note: This is not recommended for standard Disclosure-pattern navigation.\r\n *\/\r\nfunction mmm_add_aria_haspopup( $atts, $item, $args ) {\r\n    \/\/ Check if this is a menu item with children (where a sub-menu would occur)\r\n    if ( in_array( 'menu-item-has-children', $item-&gt;classes ) ) {\r\n        $atts['aria-haspopup'] = 'true';\r\n    }\r\n    \r\n    return $atts;\r\n}\r\nadd_filter( 'nav_menu_link_attributes', 'mmm_add_aria_haspopup', 10, 3 );<\/code><\/pre>\n<p>&nbsp;<\/p>\n<\/article>\n","protected":false},"excerpt":{"rendered":"<p>TL;DR: Automated accessibility tools often flag missing aria-haspopup\u00a0\u00a0attributes because they assume all menus should behave like &#8220;Desktop Applications.&#8221; However, Max Mega Menu follows the W3C Disclosure Pattern. We use aria-expanded , which provides a better experience for screen reader users and avoids confusing navigation &#8220;modes.&#8221; If you\u2019ve recently run an&#8230;<\/p>\n","protected":false},"author":1,"comment_status":"closed","ping_status":"closed","template":"","format":"standard","meta":{"_uag_custom_page_level_css":"","footnotes":""},"ht-kb-category":[14],"ht-kb-tag":[],"class_list":["post-438461","ht_kb","type-ht_kb","status-publish","format-standard","hentry","ht_kb_category-faqs"],"uagb_featured_image_src":[],"uagb_author_info":{"display_name":"Tom Hemsley","author_link":"https:\/\/www.megamenu.com\/author\/megamenu\/"},"uagb_comment_info":0,"uagb_excerpt":"TL;DR: Automated accessibility tools often flag missing aria-haspopup\u00a0\u00a0attributes because they assume all menus should behave like &#8220;Desktop Applications.&#8221; However, Max Mega Menu follows the W3C Disclosure Pattern. We use aria-expanded , which provides a better experience for screen reader users and avoids confusing navigation &#8220;modes.&#8221; If you\u2019ve recently run an...","_links":{"self":[{"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb\/438461","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb"}],"about":[{"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/types\/ht_kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/comments?post=438461"}],"version-history":[{"count":32,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb\/438461\/revisions"}],"predecessor-version":[{"id":438981,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb\/438461\/revisions\/438981"}],"wp:attachment":[{"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/media?parent=438461"}],"wp:term":[{"taxonomy":"ht_kb_category","embeddable":true,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb-category?post=438461"},{"taxonomy":"ht_kb_tag","embeddable":true,"href":"https:\/\/www.megamenu.com\/wp-json\/wp\/v2\/ht-kb-tag?post=438461"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}