ARIA Roles & Accessibility
Master ARIA roles to create accessible web experiences for all users. Learn landmark roles, widget patterns, and live regions for screen reader compatibility.
What is ARIA in HTML?
ARIA (Accessible Rich Internet Applications) is a set of attributes that tell assistive technology what a custom component is (role), what state it's in (aria-expanded, aria-checked) and how it's labelled (aria-label, aria-labelledby). Use it only when native HTML elements can't express the widget, because incorrect ARIA makes accessibility worse.
<button aria-expanded="false" aria-controls="menu">Menu</button>
<ul id="menu" hidden>β¦</ul>
<button aria-label="Close dialog">Γ</button>
<div role="status" aria-live="polite">Saved!</div>ARIA Role Fundamentals
ARIA (Accessible Rich Internet Applications) roles provide semantic meaning to HTML elements, enabling assistive technologies to better understand and navigate web content. They're essential for creating inclusive user experiences.
Landmarks
Page structure
Widgets
Interactive elements
Live Regions
Dynamic content
States
Element status
ARIA Role Categories
ποΈ Landmark Roles
- β’ banner - Site header
- β’ navigation - Navigation menus
- β’ main - Primary content
- β’ complementary - Sidebar content
- β’ contentinfo - Footer information
- β’ region - Generic landmark
ποΈ Widget Roles
- β’ button - Clickable elements
- β’ tab/tabpanel - Tab interfaces
- β’ menu/menuitem - Menu systems
- β’ progressbar - Progress indicators
- β’ slider - Range controls
- β’ dialog - Modal windows
π’ Live Regions
- β’ alert - Critical messages
- β’ status - Status updates
- β’ log - Sequential information
- β’ marquee - Scrolling content
- β’ timer - Time-sensitive info
- β’ aria-live - Custom regions
Complete ARIA Implementation
Explore comprehensive ARIA role implementation with landmarks, widgets, and live regions:
Complete ARIA implementation with landmarks, widgets, and accessibility features:
Code Editor
<!-- Prefer native elements: they need no ARIA -->
<button aria-expanded="false" aria-controls="menu" id="toggle">Menu</button>
<ul id="menu" hidden>
<li><a href="#">Profile</a></li>
<li><a href="#">Settings</a></li>
</ul>
<!-- Icon-only button needs an accessible name -->
<button aria-label="Close">β</button>
<!-- Live region: screen readers announce changes -->
<p role="status" aria-live="polite" id="status"></p>
<button id="save">Save</button>Preview
β Accessibility Features:
- β’ Semantic landmark structure
- β’ Interactive widget patterns
- β’ Live region announcements
- β’ Screen reader optimizations
- β’ Keyboard navigation support
- β’ Focus management
π― Implementation Highlights:
- β’ Complete toolbar with ARIA states
- β’ Accessible tab interface
- β’ Progress indicators with values
- β’ Menu system with keyboard support
- β’ Live announcements for updates
- β’ Screen reader only content
ARIA Best Practices
β Do:
- Use semantic HTML first, ARIA second
- Test with real screen readers
- Keep roles and states synchronized
- Provide meaningful labels and descriptions
π― Key Techniques:
- β’ Use landmarks for page structure
- β’ Implement proper focus management
- β’ Update live regions appropriately
- β’ Provide keyboard alternatives
- β’ Use descriptive labels and help text
- β’ Test with multiple assistive technologies
ARIA Roles β step by step
Understand when to use ARIA
ARIA (Accessible Rich Internet Applications) adds accessibility semantics to HTML. Use it only when native HTML can't convey the needed role, state, or property. The first rule: don't use ARIA if a native element works.
π― Quick Check
What does aria-expanded='true' communicate to screen readers?
ARIA Roles and Attributes: summary
Key points
- ARIA changes only what screen readers announce. It adds no keyboard behaviour; you must add that with JavaScript.
aria-liveregions announce dynamic updates such as toasts and form errors.aria-hidden="true"hides decorative elements from screen readers. Never put it on focusable elements.- Native
<dialog>,<details>and<button>replace many ARIA patterns.
Frequently asked questions
βΊWhen should I use aria-label?
When an interactive element has no visible text, such as an icon-only button. If visible text exists, use it, or point to it with aria-labelledby.
βΊIs role="button" the same as a <button>?
No. The role only changes what screen readers announce. You'd still need tabindex, Enter and Space key handling, and focus styles, all of which <button> gives you for free.