I understand that it is semantically acceptable to use multiple header
elements per page. According to http://html5doctor.com/the-header-element/, the main restriction on its usage is that it is supposed to contain a heading element.
It seems logical then, that each <header>
sort of resets the hierarchy of headings -- so the heading I am using in each <header>
should be a <h1>
. But this results in more or less only <h1>
s ever being used, as I rarely need to include a subheading in a given header.
My question is, which is the more appropriate usage of headings inside headers -- should they follow the hierarchy of headings on a page (so a more insignificant header would have, say, a <h4>
heading), or is it okay to set the heading of a given header as <h1>
most of the time, as it does in fact represent the heading of that particular header, not the page?
This is not the case. Only sectioning content elements (
section
,article
,aside
,nav
) and heading elements (h1
-h6
) have an influence on the heading hierarchy resp. the document outline.No. This may create a wrong document outline in some cases. The rule should be:
The
headingsfirst heading you are using in each sectioning content element (section
,article
,aside
,nav
) (resp. sectioning root elements likebody
) may beh1
. May, not must.Simply ignore
header
for making the decision which headings to use.You can have a section with
h1
but withoutheader
.You can have a section without
h1
but withheader
.You can have a section without
h1
and withoutheader
.You can have a section with
h1
and withheader
, but theh1
not being a child ofheader
.If you should use
h1
everywhere or alsoh2
-h6
? Both ways are allowed (in case you use the sectioning content elements correctly). The HTML5 (CR) spec recommends (bold by me):So if you want to follow this recommendation, use the headings elements of the corresponding heading levels (but if you need more than six levels, this is not possible to achieve, of course).
Pro: Better backwards compatibility (older user agents that don’t support sectioning content elements can still understand the outline)
Contra: Less flexibility (if you move/paste content, you’d need to adjust the heading levels)