Using the alert role
Description
This technique demonstrates how to use the alert role and describes the effect it has on browsers and assistive technology.
The alert role is used to communicate an important and usually time-sensitive message to the user. When this role is added to an element, the browser will send out an accessible alert event to assistive technology products which can then notify the user about it. The alert role is most useful for information that requires the user’s immediate attention, for example:
- An invalid value was entered into a form field
- The user’s login session is about to expire
- The connection to the server was lost, local changes will not be saved
Because of its intrusive nature, the alert role must be used sparingly and only in situations where the user’s immediate attention is required. Dynamic changes that are less urgent should use a less aggressive method, such as aria-live=”polite” or other live region roles.
Possible effects on user agents and assistive technology
When the alert role is added to an element, or such an element becomes visible, the user agent should do the following:
- Expose the element as having an alert role in the operating system’s accessibility API.
- Fire an accessible alert event using [...]