I have section tags nested underneath another section tag. Is it okay to have start the headings from 1 again?
For example:
<section>
<h1>Page Title</h1>
<section>
<h1>Section Title</h1>
<h2>Section Sub Title</h2>
<p>Sub section text</p>
</section>
<section>
<h1>Section Title</h1>
<h2>Section Sub Title</h2>
<p>Sub section text</p>
</section>
</section>
Thanks, Mark
Yes, it’s valid.
However, HTML5 encourages to use
But it’s not a requirement, so you are free to choose. Using
h1
everywhere allows for moving sections without having to adjust the heading ranks (although it would never be invalid, even if the ranks are messed up after moving) and for deep hierarchies (i.e., more than 6 levels); using the appropriate ranks might help (older) user-agents that don’t have the algorithm implemented.Also note that they encourage to
Following this advice and using
h1
everywhere, your example would be:Following both pieces of advice, it would be:
That works fine, whether or not it works style wise depends on how you define your
section
andh1-h6
tags.Just to note: Older browsers like IE 7 & 8 don't like
section
tag and will ignore some of the styles you apply to it. I like usingdiv
tags more since they don't rely on the user having a browser that supports HTML5 tags.