jonathantneal / h-element-spec

Use contextual headings in HTML
https://jonneal.dev/h-element-spec/
Creative Commons Zero v1.0 Universal
10 stars 0 forks source link

Do sections without headings count in calculating depth? #2

Open chaals opened 7 years ago

chaals commented 7 years ago

What is the level of the heading in

<body>
<h>What level am I?</h>
 <section>
    <section>
      <h>What about me?</h>
    </section>
  </section>

I think the answer currently is "one, two" but it isn't explicitly clear.

Consistently using terms from HTML like sectioning content and sectioning root would help.

jonathantneal commented 7 years ago

Great question, and thanks @chaals for the additional advice.

First, would you help understand sectioning content a bit better? From sectioning content, here is the definition of sectioning content:

Sectioning content is content that defines the scope of headings and footers.

After this definition, these elements appear; are they sectioning elements? Are they all of them?

<article> <aside> <nav> <section>

Because, in sectioning root, the example refers to an <h1> as "[a] heading of [the] explicit body section."

Does this mean <body> is also "sectioning content"?

Do you understand my confusion?

chaals commented 7 years ago

Yeah, I understand the confusion. Having worked through that section with some examples, I agree it's terrible to understand :(

Yes, article, aside, nav and section are all the "sectioning content elements". There are also sectioning roots...

Roughly, the algorithm means that nesting is defined in terms of sectioning content. h1-h6 elements without sectioning create an "implied section" - but that behaves somewhat bizarrely since it doesn't participate in the algorithm the same way sectioning content elements do :(

Likewise, sectioning roots behave a bit oddly. I didn't dig in all the way, and it seems the text is confused about it anyway.

My advice is that you should feel free to describe a different algorithm - maybe the one in HTML is not implemented just because it's horribly confusing - I have no idea. But you should be explicit in which elements you mean and how they work together, either by using the existing HTML definitions or by documenting the differences

jonathantneal commented 7 years ago

I hadn’t noticed that <body> was a sectioning root alongside <blockquote>, <details>, <dialog>, <fieldset>, <figure>, and <td>.

These elements can have their own outlines, but the sections and headings inside these elements do not contribute to the outlines of their ancestors.

What was the motivation behind sectioning roots?

It’s confusing when <body> does not contribute to the outline of its ancestor and yet I’d consider it the top-most outline of the page’s content.

My advice is that you should feel free to describe a different algorithm

Maybe. I’d like to get further information that helps me understand the motivation behind sectioning roots and why each of those elements was chosen to be assigned as such.

jonathantneal commented 7 years ago

Hey @chaals, on just one subject, would you be able to shed light on the motivation behind sectioning roots?

chaals commented 7 years ago

Not quickly, @hixie or perhaps @stevefaulkner may be able to tell you.

As far as I can tell, and this is basically as an observer: details and dialog aren't quite "part of the page", unless you asked for them. There isn't anything outside body so it would be a no-op making it a placeholder. The others might include sectioned content - or a single heading - but at a level that means unless you are in them, you wouldn't really want to know. (This is a part that doesn't convince me, although I wouldn't want to die arguing the counter-case either - I think it's a subjective call, although perhaps there is some really clear data somewhere that leads "everyone" to the same interpretation).

EliasHasle commented 5 years ago

Yes, article, aside, nav and section are all the "sectioning content elements". There are also sectioning roots...

Hm, how about header? Is its meaning even well-defined? The description from w3schools isn't exactly helpful: https://www.w3schools.com/tags/tag_header.asp