third_party/aria-practices/src/content/patterns/menubar/examples/menubar-navigation.html
Before considering use of the Menubar Pattern for site navigation, it is important to understand:
menubar pattern requires complex functionality that is unnecessary for typical site navigation that is styled to look like a menubar with expandable sections or fly outs.The following implementation of the Menubar Pattern demonstrates how a menubar can provide navigation menus. The parent menu items in the menubar represent a section of a mythical university web site and open a submenu containing menu items that link to pages within that section. The navigation system it illustrates is comparable to the navigation illustrated in the Example Disclosure Navigation Menu. As noted above, the disclosure pattern is better suited for most web sites because few sites need the additional keyboard functionality required to support the ARIA menubar and menu roles.
Similar examples include:
currentcolor value for the fill and stroke properties of the SVG polygon element is used to synchronize the color with text content. If specific colors are used to specify the fill and stroke properties, these colors will remain the same in high contrast mode, which could lead to insufficient contrast between the icon and the background or even make the icon invisible if its color matches the high contrast mode background.nav element that has an aria-label that matches the label on the menubar.| Key | Function |
|---|---|
| Space | |
| Enter |
| | Right Arrow |
| | Left Arrow |
| | Down Arrow | Opens submenu and moves focus to first item in the submenu. | | Up Arrow | Opens submenu and moves focus to last item in the submenu. | | Home | Moves focus to first item in the menubar. | | End | Moves focus to last item in the menubar. | | Character |
|
| Key | Function |
|---|---|
| Space | |
| Enter |
| | Escape |
| | Right Arrow |
| | Left Arrow |
| | Down Arrow |
| | Up Arrow |
| | Home | Moves focus to the first item in the submenu. | | End | Moves focus to the last item in the submenu. | | Character |
|
| Role | Attribute | Element | Usage |
|---|---|---|---|
banner | header |
banner role declaration is only necessary because it is an example that is nested inside the content of this page. In an actual website, the header element would be a top level element, i.e., it would have the body as its scope. If the scope of the header element were body, browsers would automatically treat the header as an ARIA banner, so the header would not need role="banner".|
| navigation | | nav | Identifies the region containing the mythical university navigation. |
| | aria-label="Mythical University" | nav | Provides an accessible name for the navigation landmark that describes the purpose of the navigation. |
| region | | section |
main landmark, but since this page already has a main landmark, role region is used to avoid having two main landmarks on the page.|
| | aria-labelledby="idref" | section | Provides the region with an accessible name from the h1 element. |
| contentinfo | | footer |
contentinfo role declaration is only necessary because the footer is an example that is nested inside the content of this page. In an actual website, the footer element would be a top level element, i.e., it would have the body as its scope. If the scope of the footer element were body, browsers would automatically treat the footer as a ARIA contentinfo landmark, so the footer would not need role="contentinfo".|
| Role | Attribute | Element | Usage |
|---|---|---|---|
menubar | ul |
menubar container for a set of menuitem elements.|
| | aria-label="string" | ul |
menubar.|
| menuitem | | a |
a element.|
| | tabindex="-1" | a | Makes the a element keyboard focusable, but not part of the tab sequence. |
| | tabindex="0" | a |
tabindex="0".tabindex="0".|
| | aria-current="page" | a |
title attribute with the text content of "Contains current page link" to indicate to screen reader users the menu item contains the current page link.|
| | aria-haspopup="true" | a | Indicates the menuitem has a submenu. |
| | aria-expanded="true" | a | Indicates the submenu is open. |
| | aria-expanded="false" | a | Indicates the submenu is closed. |
| none | | li |
listitem role of the li element.ul is serving as a menu so the li elements are not in their required list context.|
| Role | Attribute | Element | Usage |
|---|---|---|---|
menu | ul | Identifies the element as a menu container for a set of menu items. | |
aria-label="string" | ul |
menu.|
| menuitem | | a |
a element.|
| | tabindex="-1" | a | Keeps the a element focusable but removes it from the Tab sequence. |
| | aria-haspopup="true" | a | Indicates the menu item has a submenu. |
| | aria-expanded="true" | a | Indicates the submenu is open. |
| | aria-expanded="false" | a | Indicates the submenu is closed. |
| none | | li |
listitem role of the li element.ul is serving as a menu so the li elements are not in their required list context.|
To copy the following HTML code, please open it in CodePen.