--- url: "https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/" titulek: "Alert and Message Dialogs Pattern | APG | WAI | W3C" h1: "Alert and Message Dialogs Pattern" popis: "Accessibility resources free online from the international standards organization: W3C Web Accessibility Initiative (WAI)." jazyk: "en" kanonicka: "https://www.w3.org/WAI/ARIA/apg/patterns/alertdialog/" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 00:24:20" znaku: 2666 slov: 380 kodovani: "utf-8" sha256: "bc1e3a55bd78ce0bdcd91671ec52cbb36914fc18d509f2aa8e831d65778be3c7" --- Alert and Message Dialogs Pattern ## About This Pattern An alert dialog is a [modal dialog](../dialog-modal/) that interrupts the user's workflow to communicate an important message and acquire a response. Examples include action confirmation prompts and error message confirmations. The [alertdialog](https://w3c.github.io/aria/#alertdialog) role enables assistive technologies and browsers to distinguish alert dialogs from other dialogs so they have the option of giving alert dialogs special treatment, such as playing a system alert sound. ## Example [Alert Dialog Example](examples/alertdialog/): A confirmation prompt that demonstrates an alert dialog. ## Keyboard Interaction See the keyboard interaction section for the [modal dialog pattern](../dialog-modal/). ## WAI-ARIA Roles, States, and Properties - The element that contains all elements of the dialog, including the alert message and any dialog buttons, has role [alertdialog](https://w3c.github.io/aria/#alertdialog) . - The dialog container element has [aria-modal](https://w3c.github.io/aria/#aria-modal) set to `true` . - The element with role `alertdialog` has either: - A value for [aria-labelledby](https://w3c.github.io/aria/#aria-labelledby) that refers to the element containing the title of the dialog if the dialog has a visible label. - A value for [aria-label](https://w3c.github.io/aria/#aria-label) if the dialog does not have a visible label. - The element with role `alertdialog` has a value set for [aria-describedby](https://w3c.github.io/aria/#aria-describedby) that refers to the element containing the alert message. ### Note - Because marking a dialog modal by setting [aria-modal](https://w3c.github.io/aria/#aria-modal) to `true` can prevent users of some assistive technologies from perceiving content outside the dialog, users of those technologies will experience severe negative ramifications if a dialog is marked modal but does not behave as a modal for other users. So, mark a dialog modal **only when both:** 1. Application code prevents all users from interacting in any way with content outside of it. 2. Visual styling obscures the content outside of it. - The `aria-modal` property introduced by ARIA 1.1 replaces [aria-hidden](https://w3c.github.io/aria/#aria-hidden) for informing assistive technologies that content outside a dialog is inert. However, in legacy dialog implementations where `aria-hidden` is used to make content outside a dialog inert for assistive technology users, it is important that: 1. `aria-hidden` is set to `true` on each element containing a portion of the inert layer. 2. The dialog element is not a descendant of any element that has `aria-hidden` set to `true` .