Rule
Dialog names
Dialogs should have an accessible name.
- Rule
dialog-name- Type
- Best practice, not a WCAG requirement. It runs when Best practices is switched on.
- Severity
- Serious
What it checks
The rule looks at each <dialog> and each element with role="dialog" or role="alertdialog" that is shown on the page. It passes when the dialog is named by aria-labelledby, aria-label or title, and fails when it has none of them. A closed dialog is hidden, so it is not judged.
When a dialog opens, a screen reader announces its role and name. Without a name the listener hears only "dialog", with no clue what it is for or why it appeared.
Example
Fails
<div role="dialog">
<h2>Cookie settings</h2>
<p>Choose which cookies this site may use.</p>
<button type="button">Accept all</button>
</div>
Passes
<div role="dialog" aria-labelledby="cookie-title">
<h2 id="cookie-title">Cookie settings</h2>
<p>Choose which cookies this site may use.</p>
<button type="button">Accept all</button>
</div>
The engine is tested against both examples.
How to fix it
Point aria-labelledby at the dialog's heading, or give it an aria-label that says what it is.
Check your own pages
This rule runs in every pour audit: the browser extension, the bookmarklet, the command line and the editor. Get pour, free.