admin管理员组文章数量:1026620
I have a series of tricks that I use to add things like aria tags, keyboard navigation, screen reader text, and other features. I would love to see some of yours.
Assume this is a multi-tiered menu meeting WCAG 2.1 AA guidelines or better. Assume this is a typical WordPress menu and we're requiring as little content manager knowledge as you can. Assume the menu is responsive.
wp_nav_menu(
array(
'theme_location' => 'main',
'depth' => 2,
)
);
I look forward to seeing what you have!
I have a series of tricks that I use to add things like aria tags, keyboard navigation, screen reader text, and other features. I would love to see some of yours.
Assume this is a multi-tiered menu meeting WCAG 2.1 AA guidelines or better. Assume this is a typical WordPress menu and we're requiring as little content manager knowledge as you can. Assume the menu is responsive.
wp_nav_menu(
array(
'theme_location' => 'main',
'depth' => 2,
)
);
I look forward to seeing what you have!
Share Improve this question asked Mar 28, 2019 at 2:56 MikeNGarrettMikeNGarrett 2,6711 gold badge20 silver badges29 bronze badges1 Answer
Reset to default 0Kevin Leary posted a snippet to add aria-expanded tags in 2018. I love the simplicity of it.
He describes what we're doing here:
This is the recommended approach for “fly-out (or drop-down) menus” provided by the w3, more on fly-out menu accessibility can be read on their site directly.
function my_nav_menu_link_attributes( $atts, $item, $args ) {
if ( 'main' === $args->theme_location ) {
$item_has_children = in_array( 'menu-item-has-children', $item->classes );
if ( $item_has_children ) {
$atts['aria-haspopup'] = 'true';
$atts['aria-expanded'] = 'false';
}
}
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'my_nav_menu_link_attributes', 10, 3 );
I have a series of tricks that I use to add things like aria tags, keyboard navigation, screen reader text, and other features. I would love to see some of yours.
Assume this is a multi-tiered menu meeting WCAG 2.1 AA guidelines or better. Assume this is a typical WordPress menu and we're requiring as little content manager knowledge as you can. Assume the menu is responsive.
wp_nav_menu(
array(
'theme_location' => 'main',
'depth' => 2,
)
);
I look forward to seeing what you have!
I have a series of tricks that I use to add things like aria tags, keyboard navigation, screen reader text, and other features. I would love to see some of yours.
Assume this is a multi-tiered menu meeting WCAG 2.1 AA guidelines or better. Assume this is a typical WordPress menu and we're requiring as little content manager knowledge as you can. Assume the menu is responsive.
wp_nav_menu(
array(
'theme_location' => 'main',
'depth' => 2,
)
);
I look forward to seeing what you have!
Share Improve this question asked Mar 28, 2019 at 2:56 MikeNGarrettMikeNGarrett 2,6711 gold badge20 silver badges29 bronze badges1 Answer
Reset to default 0Kevin Leary posted a snippet to add aria-expanded tags in 2018. I love the simplicity of it.
He describes what we're doing here:
This is the recommended approach for “fly-out (or drop-down) menus” provided by the w3, more on fly-out menu accessibility can be read on their site directly.
function my_nav_menu_link_attributes( $atts, $item, $args ) {
if ( 'main' === $args->theme_location ) {
$item_has_children = in_array( 'menu-item-has-children', $item->classes );
if ( $item_has_children ) {
$atts['aria-haspopup'] = 'true';
$atts['aria-expanded'] = 'false';
}
}
return $atts;
}
add_filter( 'nav_menu_link_attributes', 'my_nav_menu_link_attributes', 10, 3 );
本文标签: accessibilityWhat are some of your favorite methods for creating an accessible menu
版权声明:本文标题:accessibility - What are some of your favorite methods for creating an accessible menu? 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745651569a2161351.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论