# listbox

> The `listbox` ARIA role is used for a container of selectable items from which the user can select one or more options.

## When should I use role='listbox' instead of a select?

The role that represents a widget that allows users to select one or more items from a list of options. It provides a way to present and manage multiple selectable items within a list.

- Topic: Basic Control Elements
- Type: role

## Example

Wrong:

```html
<ul>
  <li onclick="pick(this)">Red</li>
  <li onclick="pick(this)">Blue</li>
</ul>
```

Right:

```html
<ul role="listbox" aria-label="Color" tabindex="0" aria-activedescendant="c1">
  <li role="option" id="c1" aria-selected="true">Red</li>
  <li role="option" id="c2" aria-selected="false">Blue</li>
</ul>
```

The list becomes a focusable listbox with option roles and selection state, ready for arrow key handling.

## Common mistakes

- Using `role='listbox'` for a plain list of links or cards.
- Putting interactive elements, like delete buttons, inside options.

## Key points

- Every child of the `listbox` has `role='option'`, and options contain no buttons or links.
- Focus is managed with `aria-activedescendant` or roving `tabindex`, and arrow keys move it.
- Selected options have `aria-selected='true'`; multi-select lists set `aria-multiselectable='true'`.
- A native `<select>` is used when the design allows.

## Interview questions

### Does the select element have the listbox role?

Yes, when it has `multiple` or a `size` greater than 1. A single-choice dropdown `<select>` maps to `combobox`.

### Can a listbox option contain a button?

No. Options cannot contain interactive elements; use a grid if each row needs its own controls.

## Related cards

- [option](https://wonderium.dev/a11y/option.md)
- [combobox](https://wonderium.dev/a11y/combobox.md)
- [\[aria-activedescendant\]](https://wonderium.dev/a11y/aria-activedescendant.md)
- [\[aria-multiselectable\]](https://wonderium.dev/a11y/aria-multiselectable.md)
- [`<select>`](https://wonderium.dev/html/select.md)

---

- Level: [Accessibility](https://wonderium.dev/a11y.md)
- HTML version: https://wonderium.dev/a11y/listbox
- Last updated: 2026-11-25
