[whatwg] WA1 - The Section Header Problem

Matthew Raymond mattraymond at earthlink.net
Wed Nov 17 10:13:15 PST 2004


James Graham wrote:
> Matthew Raymond wrote:
> 
>>    I'm not really going to fight you on the whole keeping <h1>-<h6> 
>> thing, since HTML really only specifies them as being used for header 
>> information and having different levels of importance.
>>
>>    I still feel that, structurally speaking, there should be a 
>> <section> element for every section and subsection, even for sections 
>> that are both leaves and immediate siblings. Therefore, I'm amending 
>> my previous position with the following:
>>
>> 1) Nested headers are ignored. Therefore, this markup...
>>
>> <h1><h2>Header</h2></h1>
>>
>> ...Is the same as...
>>
>> <h1>Header</h1>
>>
>> 2) <h1>-<h6> have the same semantic value as in HTML 4.01, but are 
>> additionally defined as not having any semantic meaning related to 
>> document _structure_. 
> 
> What do you mean? How would:
> 
> <section>
> <h1>heading 1</h1>
> <section>
> <h2>heading 2</h2>
> 
> work as an outline? Would it be:
> 
[Result #1]
> heading 1
> heading 2

[Result #2]
> heading 1
> |--heading 2

[Result #3]
> {no headings}

    I'm going to assume you meant this:

| <section>
|  <h1>heading 1</h1>
| </section>
| <section>
|  <h2>heading 2</h2>
| </section>

    In that case, a outline based on semantic document structure would 
yield #1, whereas an outline based on importance would yield #2. Result 
#3 never occurs.

> or something else? Do you just mean that inside <section> <h1> through 
> <h6> are at the same place in an outline i.e. an outliner does not 
> distinguish between:
> <section>
> <h1>heading 1</h1>
> <section>
> <h2>heading 2</h2>
> </section>
> <section>
> <h3>heading 2</h3>
 > [</section>]
 > [</section>]
> 
> and
> 
> <section>
> <h1>heading 1</h1>
> <section>
> <h2>heading 2</h2>
> </section>
> <section>
> <h2>heading 2</h2>
 > [</section>]
 > [</section>]
> 
> or do you mean something else?

    With regards to document structure, yes. However, in the second 
example, the section with the <h2> heading is more important than the 
<h3> heading. This could be used to create an importance hotlist of 
sorts. Remember, structure may be defined in terms of different subject 
matters and not importance, therefore resulting in different levels of 
importance being on the same level within a structural tree.

> If you do mean that, it seems like a 
> reasonable position to me (since the HTML 4 heading model is widely 
> abused and poorly specified). In the absence of a <section> ancestor of 
> a heading, we have to fall back on <h1> being higher level than <h2> 
> which is higher level than <h3>, and so on, though.

    The idea is that outliners should structure outlines according to 
the structure established by the <section> elements first. Within that 
structure, they can establish further structure based on importance, but 
it cannot break the structure established by the <section> elements.

    Take this example:

| <section>
|  <h1>heading 1</h1>
|  <section>
|   <h2>heading 2</h2>
|   <h3>heading 3</h3>
|  </section>
| </section>

    The structure in an outline would be like this:

heading 1
+- heading 2
    +- heading 3

    However, if you had this code...

| <section>
|  <h1>heading 1</h1>
|  <section>
|   <h2>heading 2</h2>
|  <section>
|  </section>
|   <h3>heading 3</h3>
|  </section>
| </section>

    Then the outline would look like this:

heading 1    (importance: 1)
|- heading 2 (importance: 2)
+- heading 3 (importance: 3)

    Note that importance cannot be used to insert structural levels, but 
only to append them. Therefore...

| <section>
|  <h1>heading 1</h1>
|  <section>
|   <h2>heading 2</h2>
|   <h3>heading 3</h3>
|   <section>
|    <h4>heading 4</h4>
|   </section>
|  <section>
| </section>

    The above example would yield the following outline:

heading 1       (importance: 1)
|- heading 2    (importance: 2)
|- heading 3    (importance: 3)
    +- heading 4 (importance: 4)

    However, what if we wrote that example in a slightly different manner:

| <section>
|  <h1>heading 1</h1>
|  <section>
|   <h2>heading 2</h2>
|   <section>
|    <h3>heading 3</h3>
|    <h4>heading 4</h4>
|   </section>
|  <section>
| </section>

    Now we get a different structure:

heading 1
|- heading 2
    +- heading 3
       +- heading 4

>>    I'd also like to see an optional attribute for <section> called 
>> |level|, which would indicate the level of importance for all the 
>> child <h> elements in the <section>. The idea would be that...
> 
> Is there a reason for this? I mean what does the new attribute give that 
> is a) useful and b) not already possible with <hn> + <section>.

    The idea is that a child section will have the default |level| of 
its parent plus one. Look at this example:

| <section level="2">
|  <h>Level 2 Heading</h>
|  <section>
|   <h>Level 3 Heading</h>
|  <section>
| </section>

    In this example, the second <h> element is equivalent to an <h3> 
heading because the |level| of its containing <section> is related to 
the level of its parent <section>. This establishes a recursive tree 
that changes the importance of all <h> headers automatically. If you use 
<h1>-<h6> elements, you are forced to change every header tag in order 
to accomplish the same effect, which is really bad if you have a lot of 
headers inside that section (unlike the example above, which is 
deliberately simple for the purpose of understanding the concept).

> I remain unconvined that <h> is at-all compatible with the goal of 
> backward-compatibility or even particularly useful given that we have to 
> retain <h1> through <h6> so little conceptual simplifcation of the 
> language is obtained though <h>.

    I'm not sure what you mean. In this scheme, and <h> header with a 
section level of one is exactly the same as <h1>, and so forth. The <h> 
header is a way of auto-assigning the numerical importance of an <h#> 
element. In theory, if you had enough structure, <h> could be equivalent 
to a theoretical <h25> element.

    Because of this auto-assignment, you can copy and paste <section> 
elements into different levels without worrying about what importance to 
assign to the tags.



More information about the whatwg mailing list