# \[role\]

> The `role` HTML attribute specifies the accessibility role of an element, indicating its semantic meaning or purpose within the document structure.

## What does the role attribute do in HTML?

The attribute that defines the role of an element within web accessibility APIs. It helps assistive technologies, like screen readers, understand how the element should be interpreted or interacted with.

- Topic: Global Attributes
- Type: attribute
- Browser support: Chrome 103+, Chrome Android 103+, Edge 103+, Firefox 119+, Firefox Android 119+, Safari 16.4+, Safari iOS 16.4+

## Example

Wrong:

```html
<div role="button" onclick="send()">
  Send
</div>
```

Right:

```html
<button type="button" onclick="send()">
  Send
</button>
```

A role only changes what assistive tech hears. The native button also brings focus and keyboard support.

## Common mistakes

- Adding `role='button'` to a `<div>` without `tabindex` and key handling.
- Writing redundant roles like `<nav role='navigation'>`.

## Key points

- A native element is used when one exists, like `<button>` instead of `role='button'`.
- Elements with interactive roles are focusable and handle the keys that role requires.
- The `role` value is a real ARIA role and does not repeat the element's own role.

## Interview questions

### Does role add behavior to an element?

No. It changes only the semantics for assistive tech. Focus, keys and states must be added by you.

### Can I use more than one role?

Yes. You can list roles separated by spaces, and the first supported one is used as a fallback chain.

### Is role='presentation' the same as aria-hidden?

No. 'presentation' removes the element's semantics but keeps its content. `aria-hidden` hides the whole subtree.

## Related cards

- [ARIA Roles](https://wonderium.dev/a11y/aria-roles.md)
- [ARIA](https://wonderium.dev/a11y/aria.md)
- [Semantics](https://wonderium.dev/html/semantics.md)
- [presentation, none](https://wonderium.dev/a11y/presentation-none.md)
- [button](https://wonderium.dev/a11y/button.md)

---

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