I know you have accepted an answer, but it is not quite right.
Sure, you can put an <h1>
in a dialog and nothing will catch fire. It will technically not be correct, however.
The heading level should represent where it lives in the page structure. If your page has a single <h1>
, which is your best way to go, then the dialog should get a heading level that corresponds to where it lives within the structure of the page (its content).
Most likely the dialog does not fit into the flow of the rest of the content, so it would appropriately be a sub of the page's <h1>
(since it is a dialog about the page), making the dialog take <h2>
.
If you are using a tabbed interface, and you have built your tabs to each be <h2>
s, and your dialog applies to a specific tab, then your dialog would take an <h3>
.
And so on.
Adding role=document
does not change this (and may be a mis-application of the document
ARIA role unless you are explicitly testing with assistive technology to ensure it works as you expect).
You can see that the all-<h1>
model is now considered an anti-pattern in HTML 5.1. The W3C HTML validator will now flag it.
You can read more about the approach to structure headings in an article penned by one of the editors of the HTML5 spec: Computer says NO to HTML5 document outline
So, to answer your original question, no it is not semantically correct to use <h1>
in a dialog.