Accessible Modals

A modal (or dialog) is a box that pops open on top of the webpage, usually covering the whole page or a major portion of the page.

What makes an accessible modal?

In order to be accessible, modals:

  1. should be hidden with visibility: hidden ,
  2. should have an accessible name,
  3. should have a role="dialog" assigned,
  4. should move focus inside the dialog,
  5. should not allow focus outside of the box,
  6. can be closed with Esc ,
  7. can be closed with a touch/click outside of box,
  8. can be closed with a close button (if present),
  9. when closed, should return user focus to the element that initiated the modal,

Dialog Title

This is a dialog that just contains extra text. Dialogs or modals can also hold form elements.

Why create a custom modal?

The dialog element is not supported across most browsers.

People who know this stuff