Accessible Naming for ARIA Dialogs
Rule ID: aria-dialog-name
Ruleset: axe-core 4.10
User Impact: Serious
Guidelines: Deque Best Practice
How to Fix the Problem
To comply with this rule, ensure that every element using role="dialog"
or role="alertdialog"
includes a meaningful, accessible name. This name must be understandable by screen reader users. You can fix the issue by implementing one of the following markup strategies:
✅ Correct Examples
-
Using
aria-labelledby
:This approach points to another element that contains readable text.
-
Using
aria-label
:The
aria-label
attribute directly provides the name. -
Using
title
:The
title
attribute can be used as a fallback, though it’s not as robust as ARIA attributes.
❌ Incorrect Examples
Avoid the following patterns, which fail the accessibility check:
-
No label or title at all:
-
Empty
aria-label
: -
aria-labelledby
references a non-existent element: -
aria-labelledby
references an empty element:
Why it Matters
Screen reader users rely on accessible names to understand the purpose and context of a dialog. Without a name, these users may be confused or unaware of the dialog’s purpose. This is especially problematic for modals and alerts that demand user interaction, as they can appear with no context.
A missing or empty name causes screen readers to skip over the dialog or announce unhelpful default phrases like “dialog”, providing no clarity on the dialog’s function or importance. Providing an accessible name ensures all users can understand and interact with modal content.
Rule Description
All elements using role="dialog"
or role="alertdialog"
must have a discernible text label. This label provides essential information about the dialog’s purpose and helps screen reader users navigate and understand the page structure effectively.
The Algorithm (in simple terms)
The rule checks:
-
If any element has
role="dialog"
orrole="alertdialog"
. -
Then, it verifies whether the element has:
-
A non-empty
aria-label
, or -
A valid
aria-labelledby
pointing to visible and meaningful text content.
-
If neither condition is met, the rule fails.