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 listbox widget presents a list of options and allows a user to select one or more of them. A listbox that allows a single option to be chosen is a single-select listbox; one that allows multiple options to be selected is a multi-select listbox.
When screen readers present a listbox, they may render the name, state, and position of each option in the list. The name of an option is a string calculated by the browser, typically from the content of the option element. As a flat string, the name does not contain any semantic information. Thus, if an option contains a semantic element, such as a heading, screen reader users will not have access to the semantics. In addition, the interaction model conveyed by the listbox role to assistive technologies does not support interacting with elements inside of an option. Because of these traits of the listbox widget, it does not provide an accessible way to present a list of interactive elements, such as links, buttons, or checkboxes. To present a list of interactive elements, see the Grid Pattern.
Avoiding very long option names facilitates understandability and perceivability for screen reader users. The entire name of an option is spoken as a single unit of speech when the option is read. When too much information is spoken as the result of a single key press, it is difficult to understand. Long names inhibit perception by increasing the impact of interrupted speech because users typically have to re-read the entire option. And, if the user does not understand what is spoken, reading the name by character, word, or phrase may be a difficult operation for many screen reader users in the context of a listbox widget.
Sets of options where each option name starts with the same word or phrase can also significantly degrade usability for keyboard and screen reader users. Scrolling through the list to find a specific option becomes inordinately time consuming for a screen reader user who must listen to that word or phrase repeated before hearing what is unique about each option. For example, if a listbox for choosing a city were to contain options where each city name were preceded by a country name, and if many cities were listed for each country, a screen reader user would have to listen to the country name before hearing each city name. In such a scenario, it would be better to have 2 list boxes, one for country and one for city.
select
with size
attribute greater than one.select
with optgroup
children.For a vertically oriented listbox:
listbox
role supports the aria-activedescendant property, which provides an alternative to moving DOM focus among option
elements when implementing keyboard navigation. For details, see
Managing Focus in Composites Using aria-activedescendant.
listbox
.listbox
.group
are referred to as grouped optionsand form what is called an
option group.If a listbox contains grouped options, then:
listbox
is not part of another widget, such as a combobox, then it has either a visible label referenced by aria-labelledby or a value specified for aria-label.listbox
has aria-multiselectable set to true
.
Otherwise, aria-multiselectable
is either set to false
or the default value of false
is implied.
aria-selected
, then aria-checked
is not specified for any options.
Alternatively, if the selection state is indicated with aria-checked
, then aria-selected
is not specified for any options.
See notes below regarding considerations for which property to use and for details of the unusual conditions that might allow for both properties in the same listbox.
true
.
No more than one option is selected at a time if the element with role listbox
does not have aria-multiselectable set to true
.
false
.listbox
has aria-orientation set to horizontal
.
The default value of aria-orientation
for listbox
is vertical
.
aria-selected
or aria-checked
are:
aria-selected
for single-select widgets and aria-checked
for multi-select widgets.
In the absence of factors that would make an alternative convention more appropriate, this is a recommended convention.
selectitems? Or, is the visual indicator of selection a check mark?
aria-selected
and aria-checked
are extremely rare.
It is strongly recommended to avoid designing a listbox widget that would have the need for more than one type of state.
If both states were to be used within a listbox, all the following conditions need to be satisfied:
aria-selected
is different from the meaning and purpose of aria-checked
in the user interface.This is an unpublished draft preview that might include content that is not yet approved. The published website is at w3.org/WAI/.