-
AuthorPosts
-
January 26, 2026 at 1:54 am #1494302
My client’s accessibility consultants said this about the burger menu on https://abodecommunities.org/ (at widths narrower than 990px):
“The hamburger menu element is incorrectly defined as a link when it should be defined as a button. Also, the hamburger menu element does not alert the user if the menu is expanded or not.” — Does that sound correct to you, and if so can you help me address those issues?
Thanks and lmk if you have any questions!
January 26, 2026 at 9:09 am #1494306First of all, the icon is marked with aria-label=“Menu,” which is best practice.
And to understand your question correctly, they consider an anchor tag with such a label to be misleading?
So you would prefer it to be like this?by the way – all enfold buttons do not have the button tag – they got that extra-class : avia-button
January 26, 2026 at 9:31 am #1494308try this in child-theme functions.php:
function custom_replace_burger_anchor_with_button( $items, $args ){ $pattern = '/(<li[^>]*class="[^"]*av-burger-menu-main[^"]*"[^>]*>)\s*<a([^>]*)>/is'; $items = preg_replace($pattern, '$1<button type="button" $2>', $items); $items = preg_replace('/<\/a>(\s*<\/li>\s*$)/', '</button>$1', $items); return $items; } add_filter( 'wp_nav_menu_items', 'custom_replace_burger_anchor_with_button', 9999, 2 );
BUT: Please note that in this case, you will no longer need to assign all styles to the a tag, but rather to the button tag.
In this case, it might be better to use role=”button” and class=avia-button.function custom_enhance_burger_anchor_regex( $items, $args ) { $pattern = '/<a href="#" aria-label="(.*?)"/i'; $replacement = '<a href="#" role="button" class="avia-button" aria-label="$1"'; $items = preg_replace($pattern, $replacement, $items); return $items; } add_filter( 'wp_nav_menu_items', 'custom_enhance_burger_anchor_regex', 9999, 2 );No CSS break: Since it remains an anchor-tag, all Enfold styles for the menu continue to work perfectly.
A11y-compliant: With role=”button,” we tell the screen reader: “Ignore that there is a link here; treat this element like a button.”maybe it is better to not add the class avia-button because it might come into conflict with some stylings.
use a different class there f.e.: avia-burger-button
then you can easily select it via this class. -
AuthorPosts
- You must be logged in to reply to this topic.


