A screen reader needs to know what a piece of a page is, not only what it looks like. The ARIA role alertdialog describes an urgent dialog that demands a decision.
What this role means
An urgent dialog that demands a decision.
ARIA roles add meaning to the accessibility tree. They do not automatically make something clickable, move keyboard focus or build an interface. Those behaviors come from native HTML controls or from correctly implemented JavaScript.
See alertdialog in a real page
<div role="alertdialog" aria-labelledby="confirm-title" aria-modal="true">
<h2 id="confirm-title">Delete this file?</h2>
<button type="button">Cancel</button>
<button type="button">Delete</button>
</div>
Read the example
Look for role="alertdialog" in the example. The role helps assistive technology classify the content. Read the surrounding text and labels too: those give the control or region its useful name.
A scripted custom dialog still needs keyboard focus management and a working close action; prefer native dialog for new pages.
When to use it
Start with native HTML whenever possible. Add ARIA only when it provides missing meaning for an interface that you cannot build with the appropriate native element.
For custom interactive widgets, test with the keyboard and a screen reader. Depending on the pattern, you may need Enter or Space activation, arrow-key handling, state changes, focus movement and a clear accessible name. Assigning the role alone implements none of these.
Try it yourself
Put the example on a practice page and inspect it using your browser accessibility panel. If it includes interactive controls, reach them with Tab and check whether they work without a mouse. Explain whether the semantics come from native HTML or an explicit ARIA role.
Common Beginner Mistakes
- Adding
role="alertdialog"without checking whether an ordinary HTML element already supplies the right semantics. - A scripted custom dialog still needs keyboard focus management and a working close action; prefer native dialog for new pages.
- Confusing the role announced by a screen reader with the behavior that the browser implements.
Key Takeaways
alertdialogis related to an urgent dialog that demands a decision.- A scripted custom dialog still needs keyboard focus management and a working close action; prefer native dialog for new pages.
- Native HTML is the first choice; ARIA should clarify meaning, not replace working HTML.