[whatwg] Headings and sections, role of H2-H6

Charles McCathieNevile chaals at opera.com
Thu Apr 29 02:18:42 PDT 2010

On Thu, 29 Apr 2010 01:47:56 +0200, Jesse McCarthy  
<whatwg-2010-04 at jessemccarthy.net> wrote:

> I think the new section and heading model in HTML 5 is a welcome  
> development...
   I've actually essentially been doing it that way for years
> --  eschewing H2-H6 and using DIV as a stand in for SECTION.  I've  
> always considered the H1-H6 concept a mess, and thankfully that seems to  
> have been recognized by the people working on this spec.

FWIW, I asked TimBL about this a decade ago, and he effectively agreed  
with you. The reason then was the same as now - backward compatibility (in  
that case with an SGML dialect that was in relatively wide use, which had  
the structure that got adopted into HTML).

The ISO dialect of HTML more or less adopts the style in the example you  
quote, wrapping each logical section and its header in a div. But it  
requires the use of heading levels.

> My understanding is that in HTML 5 the following is acceptable, and at  
> least as acceptable as the alternative: use just H1, in conjunction with  
> SECTION; forego use of H2-H6 for the most part; and, allow heading level  
> to be determined by section nesting level.  Is that correct?

It appears to be. HTML5 defines an outline algorithm, whereas in HTML4  
none is actually formally defined, so you can use headings in whatever  
level you see fit - although they are commonly used as markers to define  
an outline/table of contents.

> There are 2 code examples shortly after that passage, and the following  
> one is indicated as being preferable to the other one because the  
> sections are explicitly marked up instead of implied:
> <body>
>  <h1>Apples</h1>
>  <p>Apples are fruit.</p>
>  <section>
>   <h2>Taste</h2>
>   <p>They taste lovely.</p>
>   <section>
>    <h3>Sweet</h3>
>    <p>Red apples are sweeter than green ones.</p>
>   </section>
>  </section>
>  <section>
>   <h2>Color</h2>
>   <p>Apples come in various colors.</p>
>  </section>
> </body>
> My point is that the passage makes it seem like using H1 throughout vs.  
> using "elements of the appropriate rank for the section's nesting level"  
> are equally sound and encouraged, and the code sample uses H2 and H3.
> I see why H2-H6 are retained for certain uses, but -- except in an  
> HGROUP --  there's no good reason to use H2-H6 when writing new code  
> with explicitly marked-up sections, is there?

Backwards compatibility - browsers, authoring tools, screen-scraping tools  
that syndicate content, User Style Sheets to improve readability,  
Assistive technologies, are all built today on the basis that different  
levels of headings imply sectioning and subsectioning, whereas almost no  
tools currently implement the new model.

It is true that the old model isn't ideal, especially for documents so  
large and complex that they have more than half a dozen levels of content.  
But up to that arbitrary limit, the current approach more or less works in  
practice. It would be trivial to extend it to 9 levels by adding more  
elements, and people could be expected to understand how that works and  
upgrade their tools without re-implementing the algorithms. Going further  
would require them to pick the difference between one- and two-digit  
numbers, and the Web shows that (surprisingly) this is often too hard for  
coders to get right, so there would be some period of brokenness still.

My conclusion is that the old model might just be a better bet for  
continuing - on the basis that it is good enough (we can define the  
algorithm that people already implement as easily as defining the section  
algorithm) and the cost of the change might not be worth the benefit it is  
expected to bring.

>  In that scenario isn't using just H1 throughout decidedly preferable to  
> using H2-H6?  And if so, then as long as authors are being strongly  
> encouraged to mark up headings a certain way, wouldn't it be ideal to  
> state a clear preference for using H1 throughout and include a third  
> code example, indicated as the ideal:

IMHO, of course



Charles McCathieNevile  Opera Software, Standards Group
     je parle français -- hablo español -- jeg lærer norsk
http://my.opera.com/chaals       Try Opera: http://www.opera.com

More information about the whatwg mailing list