These forums are currently read-only due to receiving more spam than actual discussion. Sorry.

It is currently Sat Dec 02, 2017 4:13 pm Advanced search

Question about HTML5 outline algorithm

If you are stuck or have questions regarding HTML or other Web technologies, ask your questions here. No question too dumb!

Question about HTML5 outline algorithm

Postby zerustech » Sat Jan 26, 2013 11:59 am

Hi Guys,

As per the W3C HTML5 spec, http://www.w3.org/html/wg/drafts/html/m ... l#outlines

When exiting a sectioning root element, if the stack is not empty, the new "current section" variable shall be set to the deepest child section of current section.

I don't quite understand the logic here, can someone give me any advice?

I understand the logic when exiting a sectioning element, because it makes sense to set the new "current section" variable to the last section of current outline.

But I just don't understand why it's necessary to find the deepest child section when existing a sectioning root.

Thanks
zerustech
<h6>
 
Posts: 2
Joined: Sat Jan 26, 2013 11:56 am

Re: Question about HTML5 outline algorithm

Postby zerustech » Sat Jan 26, 2013 1:53 pm

I guess I figured it out.

The following code snippets might explain why "deepest child" is necessary:
Code: Select all
<body id="section_0">
       <h1>heading.0</h1>
       <article id="section_0_1">
           <h1>heading.0.1</h1>
           <section id="section_0_1_1">
               <h1>heading.0.1.1</h1>
               <section id="section_0_1_1_1">
                   <h1>heading.0.1.1.1</h1>
               </section>
           </section>
           <figure id="section_root_0_1_1_2">
               <h1>heading.0.1.1.2</h1>
           </figure>
           <h3>substeps heading</h3>
       </article>
</body>


Without the logic of finding "deepest child", the outline will be generated as followings, which is incorrect as per the w3c spec.

  1. heading.0
    1. heading.0.1
      1. heading.0.1.1
        1. heading.0.1.1.1
      2. Substeps heading


The correct outline should look like the followings:

  1. heading.0
    1. heading.0.1
      1. heading.0.1.1
        1. heading.0.1.1.1
          1. Substeps heading
zerustech
<h6>
 
Posts: 2
Joined: Sat Jan 26, 2013 11:56 am

Re: Question about HTML5 outline algorithm

Postby JAB Creations » Sat Jan 26, 2013 2:21 pm

Almost, never repeat h1 as it's the header for the whole page, using it twice is exactly like spamming meta-keywords.

Code: Select all
<body>

<div id="section_0">
       <h1>heading.0</h1>
       <article id="section_0_1">
           <h2>heading.0.1</h2>
           <section id="section_0_1_1">
               <h3>heading.0.1.1</h3>
               <section id="section_0_1_1_1">
                   <h4>heading.0.1.1.1</h4>
               </section>
           </section>
           <figure id="section_root_0_1_1_2">
               <h3>heading.0.1.1.2</h3>
User avatar
JAB Creations
<aside>
 
Posts: 566
Joined: Tue Mar 13, 2007 4:48 am
Location: Sarasota Florida, USA


Return to Help & Advice

Who is online

Users browsing this forum: No registered users and 0 guests