Read This First
No ARIA is better than Bad ARIA. Before using any ARIA, read this to understand why.
How to build accessibility semantics into web patterns and widgets
No ARIA is better than Bad ARIA. Before using any ARIA, read this to understand why.
A menu is a widget that offers a list of choices to the user, such as a set of actions or functions. Menu widgets behave like native operating system menus, such as the menus that pull down from the menubars commonly found at the top of many desktop application windows. A menu is usually opened, or made visible, by activating a menu button, choosing an item in a menu that opens a sub menu, or by invoking a command, such as Shift + F10 in Windows, that opens a context specific menu. When a user activates a choice in a menu, the menu usually closes unless the choice opened a submenu.
A menu that is visually persistent is a menubar. A menubar is typically horizontal and is often used to create a menu bar similar to those found near the top of the window in many desktop applications, offering the user quick access to a consistent set of commands.
A common convention for indicating that a menu item launches a dialog box is to append "…" (ellipsis) to the menu item label, e.g., "Save as …".
The following description of keyboard behaviors assumes:
menubar
containing several menuitem
, menuitemradio
, or menuitemcheckbox
elements.menuitem
elements in the menubar
have child submenus that contain vertically arranged items.menuitem
elements in the submenus have child submenus with items that are also vertically arranged.When reading the following descriptions, also keep in mind that:
menuitem
, menuitemradio
, or menuitemcheckbox
, are referred to as items.menuitem
elements, the specific role name is used.menu
.
When a menu
opens, or when a menubar
receives focus, keyboard focus is placed on the first item.
Because menubar
and menu
elements are composite widgets as described in the practice for
Keyboard Navigation Inside Components,
Tab and Shift + Tab do not move focus among the items in the menu.
Instead, the keyboard commands described in this section enable users to move focus among the elements in a menubar
or menu
.
menubar
:
menubar
for the first time, focus is set on the first menuitem
.menubar
has previously contained focus, focus is optionally set on the menuitem
that last had focus.
Otherwise, it is set on the first menuitem
that is not disabled.
menuitem
in a menu
or menubar
, move focus out of the menu
or menubar
, and close all menus and submenus.menu
.
Unlike a menubar
, a menu
is not visually persistent, and authors are responsible for ensuring focus moves to an item inside of a menu
when the menu
opens.
menuitem
that has a submenu, opens the submenu and places focus on its first item.menuitemcheckbox
, changes the state without closing the menu.menuitemradio
that is not checked, without closing the menu, checks the focused menuitemradio
and unchecks any other checked menuitemradio
element in the same group.menuitem
that has a submenu, opens the submenu and places focus on its first item.menuitem
that does not have a submenu, activates the menuitem
and closes the menu.menuitem
in a menubar
, and that menuitem
has a submenu, opens the submenu and places focus on the first item in the submenu.menu
, moves focus to the next item, optionally wrapping from the last to the first.menu
, moves focus to the previous item, optionally wrapping from the first to the last.menuitem
in a menubar
, and that menuitem
has a submenu, opens the submenu and places focus on the last item in the submenu.menubar
, moves focus to the next item, optionally wrapping from the last to the first.menu
and on a menuitem
that has a submenu, opens the submenu and places focus on its first item.menu
and on an item that does not have a submenu, performs the following 3 actions:
menubar
.menuitem
with a submenu, either: (Recommended) opens the submenu of that menuitem
without moving focus into the submenu, or opens the submenu of that menuitem
and places focus on the first item in the submenu.menubar
were not present, e.g., the menus were opened from a menubutton, Right Arrow would not do anything when focus is on an item that does not have a submenu.
menubar
, moves focus to the previous item, optionally wrapping from the first to the last.menu
, closes the submenu and returns focus to the parent menuitem
.menubar
, performs the following 3 actions:
menubar
.menuitem
with a submenu, either: (Recommended) opens the submenu of that menuitem
without moving focus into the submenu, or opens the submenu of that menuitem
and places focus on the first item in the submenu.menu
or menubar
.menu
or menubar
.menuitem
, from which the menu was opened.menuitem
elements that both perform a function and open a submenu.
In such implementations, Enter and Space perform a navigation function, e.g., load new content, while Down Arrow, in a horizontal menubar, opens the submenu associated with that same menuitem
.
menubar
are arranged vertically and items in menu
containers are arranged horizontally:
menu
element is:
menu
element as its parent menuitem
.menuitem
.menu
or true
.false
when its child menu is not visible and set to true
when the child menu is visible.tabindex
set to -1
or 0
and aria-activedescendant set to the ID of the focused item.tabindex
set to -1
, except in a menubar, where the first item has tabindex
set to 0
.true
.true
.menubar
has aria-labelledby set to a value that refers to the labelling element.
Otherwise, the menubar element has a label provided by aria-label.
vertical
.
The default value of aria-orientation
for a menubar is horizontal
.
menu
either has:
horizontal
.
The default value of aria-orientation
for a menu is vertical
.
If aria-owns is set on the menu container to include elements that are not DOM children of the container, those elements will appear in the reading order in the sequence they are referenced and after any items that are DOM children. Scripts that manage focus need to ensure the visual focus order matches this assistive technology reading order.
This is an unpublished draft preview that might include content that is not yet approved. The published website is at w3.org/WAI/.