Skip to content

QuizNot attempted

Naming a dialog

What is the cleanest way to give a modal dialog its accessible name when it already has a visible <h2>?
1–4 to choose, Enter to submit
Show answer & explanation

Correct answer:

  • aria-labelledby pointing at the <h2>'s id
  • aria-labelledby reuses the visible <h2> as the dialog's name, so it can never drift from what sighted users see
  • add aria-describedby for the body text.
  • Not a hidden duplicate label: duplicate text drifts out of sync.
  • Not title: unreliably announced and shows a hover tooltip.
  • Not role=heading on the dialog: replaces the dialog role, it doesn't name it.