aria-hidden="true" removes an element and its descendants from the accessibility tree. It does not visually hide the element.
<span aria-hidden="true">★</span>
<span>5 out of 5 stars</span>Do not apply aria-hidden="true" to focusable elements or their ancestors while they remain keyboard-accessible. Use the HTML hidden attribute when content should be hidden visually and from assistive technology.
8. aria-live
aria-live can announce dynamic updates to assistive technology. It is useful for messages such as form submission results.
<p id="status" role="status" aria-live="polite"></p>When JavaScript updates the text, assistive technology may announce the change. Use live regions thoughtfully; frequent or unnecessary announcements can be disruptive.
9. Accessible Error Messages
<label for="user-email">Email</label>
<input id="user-email" name="email" type="email"
aria-describedby="email-error" aria-invalid="true">
<p id="email-error">Enter a valid email address.</p>In this example, the field is already in an invalid state. A real application should set aria-invalid and update the error text according to actual validation results. Do not mark a field invalid before it has actually failed validation unless that is appropriate for the interface.
Common Mistakes
- Using ARIA when a native semantic element already works.
- Adding roles without implementing the expected keyboard interaction.
- Leaving aria-expanded unchanged when a panel opens or closes.
- Using aria-hidden to hide content visually.
- Adding aria-live regions that announce too many changes.
Practice Exercises
- Add an accessible name to an icon-only close button.
- Associate a password field with help text using aria-describedby.
- Build a static expandable-menu example using aria-controls and aria-expanded.
- Explain why a native button is usually better than a clickable div.
Revision Quiz
- What does ARIA stand for?
- What does aria-label provide?
- Which attribute associates a control with descriptive help text?
- What does aria-expanded communicate?
- Does aria-hidden visually hide an element?
- Does ARIA automatically implement keyboard behavior?
Answer Key and Explanations
- Accessible Rich Internet Applications — ARIA adds accessibility semantics to interfaces.
- An accessible name — It can name a control when visible text is not sufficient.
- aria-describedby — It points to text that describes the control.
- Whether associated content is expanded — Its value should match the interface state.
- No. It hides content from the accessibility tree, not from visual display.
- No. Keyboard behavior must be implemented or provided by native HTML.