Alerts
Alerts are an important type of ARIA live region which provide screen readers with ways to announce meaningful information to a user. These alerts are triggered programmatically, usually based on a user interaction or timer. They announce text to the use without moving keyboard focus. Since they are intended to stand out from other content on the page, they should be styled and positioned on the page close to the user’s mouse or element that has keyboard focus.
Applicable WCAG 2.1 Success Criteria
- 1.3.1 Info and Relationships (level A): Information, structure, and relationships conveyed through presentation can be programmatically determined or are available in text.
- 4.1.2 Name, Role, Value (level A): For all user interface components (including but not limited to: form elements, links and components generated by scripts), the name and role can be programmatically determined; states, properties, and values that can be set by the user can be programmatically set; and notification of changes to these items is available to user agents, including assistive technologies.
Features
- Activation: Alerts are activated by a user interaction, timer, or other method.
- Keyboard Focus: Focus must not be moved when an alert is activated.
- Design: Distinct from other visual content on page.
- Position: Should be positioned close to the user’s mouse, or element / region of page that currently has focus. This is to ensure that users using screen magnifiers will be aware of the alert.
- Message text and length: Messages should be concise and brief. If an icon is used to convey semantics (warning, success, etc.), make sure that the meaning of the icon is communicated in the alert text.
Implementation Notes
- An empty ARIA live region MUST be present in the DOM on page load.
- The ARIA live region MUST be empty on page load.
- Another ARIA live region can be added to the DOM later, but it MUST be empty.
- If an ARIA live region is added to the DOM without a page load / refresh event, a JavaScript delay should be used before putting content into the live region.
Demo
Code
Browser and Screen Reader support
Tested using | Firefox with JAWS | Chrome | Safari iOS with Voiceover | IE with JAWS | Edge with Narrator |
---|