Accessibility

a11y/dialog-name

Every dialog has an accessible name, usually aria-labelledby pointing at its visible heading.

seriousstaticWCAG 4.1.2 · Afe-a11y-dialog

Why

When a dialog opens, a screen reader announces its name and role first. Without a name the user hears only "dialog" and must explore it to learn whether it is a confirmation, an error or a form.

Fix

Give the dialog a visible heading with an id and set aria-labelledby to it; use aria-label only when there is no visible title. For an alert dialog, also point aria-describedby at the message.

Examples

<!-- bad -->
<dialog><h2>Delete project?</h2>…</dialog>
<!-- good -->
<dialog aria-labelledby="del-title"><h2 id="del-title">Delete project?</h2>…</dialog>

Sources

Facts

Id
a11y/dialog-name
Severity
serious
Check
static checked in the source by audit
Applies to
html angular vue svelte astro jsx
WCAG 2.2
4.1.2, level A
Same problem in
axe-core aria-dialog-name
Taught by the skill
fe-a11y-dialog Dialogs and modals
Since version
0.1.0

Rule file on GitHub

Read it in the terminal

npx github:dawidolko/frontend-skills explain a11y/dialog-name