Accessibility and User Notification of Changes
One of the most challenging aspects of web accessibility is communicating to users that something has changed on the page, that content is loading, or that a background update has occurred without moving their keyboard f
One of the most challenging aspects of web accessibility is communicating to users that something has changed on the page, that content is loading, or that a background update has occurred without moving their keyboard focus. For these scenarios, ARIA provides aria-live, aria-atomic, aria-relevant, and aria-busy.
aria-live
aria-live indicates that a region is "live," meaning its content will be dynamically updated and assistive technologies (such as screen readers) should announce those changes. This attribute accepts the following values:
-
off: Changes will not be announced unless the user currently has focus on that region. This is the default value and is used for non-critical updates. -
polite: Updates will be announced without interrupting the user; the screen reader will wait until the user finishes their current task or reading before announcing the change. -
assertive: Updates are communicated immediately, interrupting whatever the screen reader is currently saying. Because this can disorient the user, it should be reserved for urgent warnings or critical errors.
For reliable support across screen readers, the element with aria-live should already exist in the DOM before the dynamic content is injected into it.
Example
<p aria-live="assertive">
You have 15 seconds to fill out the form
</p>
aria-atomic
This property specifies whether assistive technologies should announce the entire live region or only the specific part that changed when an update occurs. The possible values are:
-
true: The screen reader will announce the entire region as a whole, providing full context. -
false: Only the specific node that changed will be announced (default).
For example, with aria-atomic="true", even if only the number inside the <span> changes, the entire sentence will be read aloud so the user understands the context:
<p aria-live="polite" aria-atomic="true">
You have <span>5 ββminutes left</span> to continue shopping
</p>
aria-relevant
With aria-relevant, we indicate what types of DOM mutations within the live region should trigger an announcement. The values are:
-
additions: Announces elements added to the DOM. -
removals: Announces elements removed from the DOM (use with caution, as this can create unnecessary noise). -
text: Announces text changes inside existing nodes. -
all: Equivalent toadditions removals text.
By default, browsers treat aria-relevant as additions text. In the following example, only newly added elements will be announced:
<div aria-live="polite" aria-relevant="additions"></div>
aria-busy
We use aria-busy when multiple parts of a region are being updated at the same time (for instance, while fetching data), telling assistive technologies to wait until the update is complete before announcing changes.
-
false: Changes are announced as they happen (default). -
true: Assistive technologies will hold off on announcing updates inside the region until the attribute is switched back tofalse.
Example:
<section aria-live="polite" aria-busy="true">
Loading results...
</section>
Other resources
Originally published by Dev.to WebDev. Aggregated on AIWithGhost for educational purposes β full credit and traffic to the original publisher.