ARIA dialogs and alert dialogs should have an accessible name

Every element with `role="dialog"` or `role="alertdialog"` should have an accessible name, usually its visible heading, so users know what opened. This is a best practice, not a WCAG requirement.

Rule IDaria-dialog-name
ImpactSerious
Success criterion Best practice, not a WCAG requirement
Readabler fix Fixed with a text: from the page or written by AI

Example

Before
<div role="dialog" aria-modal="true">
  <h2>Choose a delivery slot</h2>
  <button type="button">Close</button>
</div>

When focus moves in, a screen reader says only “dialog”, then “Close, button”.

After
<div role="dialog" aria-modal="true" aria-labelledby="slot-title">
  <h2 id="slot-title">Choose a delivery slot</h2>
  <button type="button">Close</button>
</div>

A screen reader says “Choose a delivery slot, dialog” as soon as it opens.

Why it matters

When a dialog opens, focus moves into it and the rest of the page goes inert. Sighted users see the title at once. Screen reader users only hear what the browser announces, and without a name that is just “dialog”, followed by whatever element received focus. They must explore the dialog to find out why it appeared.

This is a bigger problem for alert dialogs, which interrupt the user with something urgent: an expiring session, a payment error or a request to confirm a deletion. If the purpose is not announced, people may dismiss the dialog without understanding the consequence.

Named dialogs also help voice control and screen magnifier users keep track of where they are. This rule is a best practice rather than a WCAG requirement.

How to fix it

Name the dialog after its visible title.

The dialog has a heading. Point aria-labelledby at it. This keeps the spoken and visible names identical:

<div role="alertdialog" aria-modal="true" aria-labelledby="del-title" aria-describedby="del-desc">
  <h2 id="del-title">Delete saved address?</h2>
  <p id="del-desc">This cannot be undone.</p>
  <button type="button">Delete</button>
  <button type="button">Cancel</button>
</div>

Adding aria-describedby to the message, as above, lets screen readers read the key text of an alert dialog straight away.

No visible title. Use aria-label:

<div role="dialog" aria-modal="true" aria-label="Product image gallery">…</div>

Native <dialog> element. It needs a name too; use the same attributes:

<dialog aria-labelledby="login-title">
  <h2 id="login-title">Sign in to your account</h2>
</dialog>

Check that the id you reference exists and is unique, especially when several dialogs share one template. Keep the name short: a title such as “Edit address” works better than a full sentence, because screen readers repeat it whenever focus returns to the dialog.

Checklist

  1. Give every dialog and alertdialog a name.
  2. Point aria-labelledby at the dialog's visible heading.
  3. Use aria-label when there is no visible title.
  4. Describe alert dialog messages with aria-describedby.

How the check works

The check finds elements with role="dialog" or role="alertdialog". It passes when the element has a non-empty aria-label, an aria-labelledby that references text, or a title attribute. Otherwise it fails. Open the dialog with a screen reader to confirm the name is announced and describes its purpose.

Resources

Updated October 27, 2026