ARIA roles describe element purpose for assistive technologies. They improve accessibility when native semantics aren’t available, but should not replace proper HTML tags. ARIA should match real behavior; incorrect roles hurt accessibility. Test with keyboard navigation and screen readers.
What are ARIA roles and why are they important in modern HTML?
Use guided tracks for structured prep, then practice company-specific question sets when you want targeted interview coverage.
Overview
ARIA (Accessible Rich Internet Applications) defines roles and properties that help assistive technologies understand the purpose of elements, especially when default HTML semantics aren’t enough.
Type | Example | Purpose |
|---|---|---|
Roles |
| Defines the element’s function or type. |
States |
| Describes the current state of an element. |
Properties |
| Provides additional context or labels. |
Example: Custom Button Using ARIA
<div role="button" tabindex="0" aria-pressed="false">Play</div>
This <div> visually acts as a button, but ARIA roles and attributes make it accessible to screen readers and keyboard users.
Why ARIA Matters
- Makes custom UI components understandable to assistive technologies.
- Improves accessibility without changing visual design.
- Ensures compliance with accessibility standards (WCAG, ADA).
- Bridges the gap between visual and semantic meaning.
Practical scenario
You build a custom dropdown, so you must apply correct ARIA roles and keyboard behavior to make it accessible.
Common pitfalls
- Adding roles to native elements that already have the correct semantics.
- Setting a role without matching keyboard interactions or ARIA states.
- Forgetting to update
aria-expandedandaria-selected.
Native elements require less ARIA, but custom UI needs careful roles. Test with keyboard-only navigation and a screen reader.
Think of ARIA roles as name tags for custom elements — they tell screen readers what each component actually is and what it does.
- ARIA defines roles, states, and properties for accessibility.
- Essential when native HTML elements are replaced with custom ones.
- Improves usability for users relying on screen readers.
- Always prefer native semantics before adding ARIA manually.