The roleglobal attribute declares an ARIA role — how assistive technologies should interpret an element. Use it for custom widgets when no native HTML element provides the right semantics.
Prefer native elements first: <button>, <nav>, <dialog>, headings, lists, and form controls already expose roles correctly. Adding the wrong role can hurt accessibility.
First rule of ARIA.
If a native element exists for the job, use it. role fills gaps; it does not replace good HTML.
Role alone is not enough.
Custom widgets also need keyboard support, focus management, and matching aria-* states.
Syntax
HTML Syntax
syntax.html
<element role="rolename">
Value is an ARIA role token such as button, dialog, navigation, or status.
role="navigation" is a fallback, not a first choice.
Audit with a screen reader or accessibility tree tools.
Edge Cases & Pitfalls
Wrong roles are worse than no roles.
native
Do not override good semantics
Avoid role on elements that already expose the correct role unless fixing a real bug.
keyboard
Interactive roles need keyboards
role=button without Enter/Space support fails accessibility.
name
Accessible name still required
Use text content, aria-label, or aria-labelledby.
presentation
none/presentation strip meaning
Never use them on focusable or meaningful controls.
Compatibility
Browser Support
role is an HTML attribute for browsers. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
role
ARIA role is supported across modern assistive technologies and browsers.
98%Global support (approx.)
Google ChromeAll modern
Full support
Mozilla FirefoxAll modern
Full support
Apple SafariAll modern
Full support
Microsoft EdgeAll modern
Full support
OperaAll modern
Full support
Samsung InternetAll modern
Full support
Internet ExplorerPartial / legacy
Partial
roleWidely supported
Bottom line: Safe to use. Prefer semantic HTML first; validate custom widgets with a screen reader.
Remember
Key Takeaways
Role: declare accessibility semantics for assistive tech.
Prefer native HTML whenever a built-in element exists.
Pair with ARIA and real keyboard support for custom widgets.
Do not override correct native roles without a strong reason.
One line:role exposes ARIA semantics — use it to fill gaps, not to replace good HTML.
Frequently Asked Questions
It tells assistive technologies what an element is supposed to be in the accessibility tree — for example button, dialog, or navigation — when native HTML semantics are not enough.
No. Prefer native elements (<button>, <nav>, <dialog>, …). Add role only when you must build custom widgets that lack a native equivalent.
Yes. role can appear on any element, though many roles only make sense in specific patterns with supporting ARIA attributes and keyboard behavior.
They remove implicit semantics (useful for decorative tables/images). Prefer modern none; do not strip semantics from interactive controls.
It exposes button semantics, but you must still add tabindex, keyboard handlers, and disabled/pressed states yourself. A real <button> is safer.
role sets the widget type; aria-* properties and states fill in name, expanded, selected, and other details.