A WAI ARIA role defines what a hTML element is or does. An ARIA role can also overwrite the standard role of HTML. A role of <a> is a link. This role can be over written by role=”button”. Screen reader will recognize the <a> element as button.
An alert role is a type of live region with important, and usually time-sensitive, information. An alert role is a simple way of providing a message to the user. More specifically, an alert role is used when the user interaction is not required but the message should be conveyed. The alert role is most useful for information that requires the user’s immediate attention, Eg: error displayed for invalid input, session time-out etc. Messages that does not need users immediate attention can have aria-live set to polite. In case of audio indication alert role helps as substitute for a hearing impaired users,
Role=”alert” should be provided in the node containing the alert message. Focus is not required to be set for these kinds of alert messages. Elements that have role=”alert” have an implicit value of aria-live=â€assertive. Alert role also has an implicit status of aria-atomic=”true”.
If the alert need to be closed by the user , use Alertdialog roleinstead. Use alert role with care, because screen readers may interrupt current output (whether it’s speech or braille) and immediately announce or display the alert message. Screen magnifiers may visually indicate that an alert occurred and what the alert text was.
- ARIA design practices for alert role W3C
- ARIA 19, technique for error identification with alert role W3C
- Using alert role to identify errors Paul Adam
- Using alert role MDN