The HTML 5 spec says:
Sections may contain headings of any rank, but authors are strongly encouraged to either use only h1 elements, or to use elements of the appropriate rank for the section's nesting level.
Authors are also encouraged to explicitly wrap sections in elements of sectioning content, instead of relying on the implicit sections generated by having multiple headings in one element of sectioning content.
http://www.w3.org/TR/2011/WD-html5-author-20110809/headings-and-sections.html#headings-and-sections
So I think both your examples are fine:
- In your first example, each
<section>
has an<h2>
tag for its heading, which is appropriate as each section is nested at the second level within the article. - In your second example, each
<section>
uses an<h1>
tag, which is appropriate as the<section>
tag is sectioning content.
And in both cases, you’ve explicitly wrapped the article sections in a <section>
tag.
I think <h2>
-<h6>
are kept around for backwards-compatibility and flexibility. Allowing HTML4-style sectioning with <h2>
-<h6>
means that existing HTML4 content doesn’t have to be altered to fit in with HTML5’s sectioning rules. It also means that if, for whatever reason, in a given situation it’s more optimal to use old-style sectioning, then authors can.
HTML is intended for worldwide general-purpose use. A bit of flexibility really helps with that.