[whatwg] Re: <section> and headings

James Graham wrote:

> <section>
> <h>Newspaper name</h>
> <section>
> <h1>Main Headline</h1>
> </section>
> <section>
> <h2>Other story</h2>
> </section>
> </section>
>
> ...skip...
>
> Insofar as headings are ever used, they are almost always used 
> incorrectly (one cannot generate an outline view of the document from 
> the headings as marked up).

I beleive there are methods of doing this more or less reliably. I once 
made a Javascript function which generates an outline for the HTML 
document with the structure very similar to given except that it treats 
ordinary <div>s as <section>s. You can see it in action here: 
http://SoftwareManiacs.Org/TOC.htm

In a nutshell it considers each <div> as a start of a new hierarchy 
subtree. The number of a first heading inside a section becomes 
top-level for this section.

For given example the outline could be:
Newspaper name
  Main Headline
  Other story

And if <h3> will be added following the <h2>Other story</h2> the outline 
could be:
Newspaper name
  Main Headline
  Other story
    Subsection of a story

Received on Tuesday, 31 August 2004 06:32:07 UTC