[role]
Example
<div role="button" onclick="send()">
Send
</div><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>withouttabindexand key handling. - Writing redundant roles like
<nav role='navigation'>.
Key points
- A native element is used when one exists, like
<button>instead ofrole='button'. - Elements with interactive roles are focusable and handle the keys that role requires.
- The
rolevalue 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.