Careeroza
ARIA Basics
What is ARIA?
ARIA (Accessible Rich Internet Applications) attributes add accessibility information that HTML alone cannot express, for custom widgets like tabs, menus and live notifications.
Note: The first rule of ARIA: do not use ARIA if a native HTML element does the job. A <button> is better than <div role="button">.
Common ARIA Attributes
| Attribute | Purpose |
|---|---|
aria-label | accessible name when there is no visible text |
aria-labelledby / aria-describedby | name or description taken from another element |
aria-expanded | whether a menu/accordion is open |
aria-hidden="true" | hide decorative content from screen readers |
aria-live="polite" | announce updates (e.g. "Item added to cart") |
role | what a custom element is: dialog, tablist, alert... |
Example: Disclosure Button
Example
The button tells assistive technology whether the panel is open:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<button aria-expanded="false" aria-controls="faq1" onclick="
const open = this.getAttribute('aria-expanded') === 'true';
this.setAttribute('aria-expanded', String(!open));
document.getElementById('faq1').hidden = open;">
What is HTML?
</button>
<div id="faq1" hidden>
<p>HTML is the standard markup language for web pages.</p>
</div>
</body>
</html>Result