[whatwg] <h1> to <h6> in <body>

The header elements have always been troubling because of their
disconnected nature, but your definition seems a bit counterintuitive
in a couple places.

Firstly, I don't think a paragraph preceding a section header should
be associated with that section. For instance, if one puts a
commentary before a book (and thus before Chapter 1), the commentary
isn't meant to be part of Chapter 1.

Second, I take issue with the way sections carry past nested elements
such as the ordered list. In your example, this would apply to the
paragraph immediate after the ol (I don't think it should be part of
section H, but rather the last section defined before the ol--section
E.

Likewise, this applies to the paragraph immediately following the div
under section J; I believe the paragraph should also be in section J
rather than the nested section K.

The issue here seems to be the precedence of hierarchy and whether it
is controlled first by the header elements, regardless of nesting, or
if the structure of the document is taken into account before the
header elements themselves.

See my illustration [1] of the differences between Hixie's model and
my own to see these two small differences more clearly.

Essentially, as is shown in the illustration, my revised definition
would be the following:

  <body>
   <p>...</p>               (part of an unnamed section)
   <h1>A</h1>                      A
   <h2>B</h2>               1.     B
   <h3>C</h3>               1.1.   C
   <h2>D</h3>               2.     D
   <h3>E</h3>               2.1.   E
   <p>...</p>               (part of section started by E)
   <ol>                     (part of section started by E)
    <li><h3>F</h3></li>     2.2.   F
    <li><h3>G</h3></li>     2.3.   G
    <li><h3>H</h3></li>     2.4.   H
   </ol>                    (part of section started by E)
   <p>...</p>               (part of section started by E)
   <h4>I</h4>               2.4.1  I
   <h2>J</h2>               3.     J
   <div>                    (part of section started by J)
    <p>...</p>              (part of section started by J)
    <h2>K</h2>              4.     K
    <p>...</p>              (part of section started by K)
   </div>                   (part of section started by J)
   <p>...</p>               (part of section started by J)
   <h3>L</h3>               4.1.   L
   <h2>M</h2>               5.     M
   <h4>N</h4>               5.0.1. N
   <h3>O</h3>               5.1.   O
   <h1>P</h1>                      P (new section after A)
   <h1>Q</h1>                      Q (new section after P)
   <h2>R</h2>               1.     R
  </body>

I don't have any particular hard-set principles to back up my proposed
definition, but it makes more intuitive sense to me to take into
consideration the structure of the document instead of ignoring it and
paying attention only to the linear association elements have with
respect to header elements and their individual precedence. Maybe
others share my view?

[1] - http://xkr.us/misc/sections.html

-- 
Brad Fults
NeatBox

On Thu, 31 Mar 2005 00:58:45 +0000 (UTC), Ian Hickson <ian at hixie.ch> wrote:
> 
> I've reached the point in my ambitious attempt at defining HTML's elements
> for the Web Apps spec [1] where I have to define <h1> - <h6>.
> 
> There are two big issues here:
> 
>  1. What do <h1> to <h6> mean in a <body>?
> 
>  2. What do <h1> to <h6> mean in a <section>?
> 
> The second question has already spawned a lot of mail on this list, and I
> will be replying to them soon. However, I want to first deal with the
> first question, which we have so far not addressed.
> 
> To rephrase the question a little, what would we want to put in HTML4 if
> we were writing an errata for HTML4 section 7.5.5?
> 
> Currently, that spec says:
> 
> # A heading element briefly describes the topic of the section it
> # introduces. Heading information may be used by user agents, for example,
> # to construct a table of contents for a document automatically.
> #
> # There are six levels of headings in HTML with H1 as the most important
> # and H6 as the least. Visual browsers usually render more important
> # headings in larger fonts than less important ones.
> 
> ...from which we gather the following conformance requiremnts:
> 
>  1.
> 
> (No, I didn't forget to fill in the list.)
> 
> So not much to start from. From common sense and current practice we can
> derive a simplistic list of things we want the definition to include:
> 
>  * Each header starts an implied section.
> 
>  * The section starts at the header and continues to the next
>    header of that level or above.
> 
>  * Sections can be nested.
> 
> However, are there other rules? What happens if a header is in an <li>,
> does its section continue after its <ol>? What about if an <h2> has as its
> next sibling an <h4>, does an <h3>-level section get implied? What about
> if there are multiple <h1> elements on the page? What if there is no <h1>
> but there is an <h2>? (What if it is followed by an <h1>?) What section
> does text before the first header get associated with?
> 
> My current thinking is to define it such that the following document
> fragment works out as described:
> 
>    <body>
>     <p>...</p>               (part of section started by A)
>     <h1>A</h1>                      A
>     <h2>B</h2>               1.     B
>     <h3>C</h3>               1.1.   C
>     <h2>D</h3>               2.     D
>     <h3>E</h3>               2.1.   E
>     <p>...</p>               (part of section started by E)
>     <ol>                     (part of section started by E)
>      <li><h3>F</h3></li>     2.2.   F
>      <li><h3>G</h3></li>     2.3.   G
>      <li><h3>H</h3></li>     2.4.   H
>     </ol>                    (part of section started by H)
>     <p>...</p>               (part of section started by H)
>     <h4>I</h4>               2.4.1  I
>     <h2>J</h2>               3.     J
>     <div>                    (part of section started by J)
>      <p>...</p>              (part of section started by J)
>      <h2>K</h2>              4.     K
>      <p>...</p>              (part of section started by K)
>     </div>                   (part of section started by K)
>     <p>...</p>               (part of section started by K)
>     <h3>L</h3>               4.1.   L
>     <h2>M</h2>               5.     M
>     <h4>N</h4>               5.0.1. N
>     <h3>O</h3>               5.1.   O
>     <h1>P</h1>                      P (new section after A)
>     <h1>Q</h1>                      Q (new section after P)
>     <h2>R</h2>               1.     R
>    </body>
> 
> The outline would be:
> 
>   Document
>     |
>     +-- A
>     |   |
>     |   +-- 1. B
>     |   |   |
>     |   |   +-- 1.1 C
>     |   |
>     |   +-- 2. D
>     |   |   |
>     |   |   +-- 2.1 E
>     |   |   |
>     |   |   +-- 2.2 F
>     |   |   |
>     |   |   +-- 2.3 G
>     |   |   |
>     |   |   +-- 2.4 H
>     |   |       |
>     |   |       +-- 2.4.1 I
>     |   |
>     |   +-- 3. J
>     |   |
>     |   +-- 4. K
>     |   |   |
>     |   |   +-- 4.1 L
>     |   |
>     |   +-- 5. M
>     |       |
>     |       +-- 5.0 <untitled>
>     |       |   |
>     |       |   +-- 5.0.1 N
>     |       |
>     |       +-- 5.1 O
>     |
>     +-- P
>     |
>     +-- Q
>         |
>         +-- 1. R
> 
> Any objections? Any other edge cases that I have forgotten?
> 
> [1] http://whatwg.org/specs/web-apps/current-work/#semantics
> 
> --
> Ian Hickson               U+1047E                )\._.,--....,'``.    fL
> http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
> Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'
>

Received on Wednesday, 30 March 2005 18:37:01 UTC