[whatwg] On tag inference

Lachlan Hunt lachlan.hunt at lachy.id.au
Mon Sep 5 03:10:05 PDT 2005


Henri Sivonen wrote:
> What about the interaction of <section> with <head> and <body>?
> 
> How would you insert the optional tags in this case:
> 
> <!DOCTYPE html>
> <title>...</title>
> <section>...</section>
> <div>...</div>
> 
> ?
> 
> My tentative assumption has been
> <!DOCTYPE html>
> <html><head><title>...</title>
> </head><body><section>...</section>
> <div>...</div></body></html>

That is how I would recommend it be defined.  It's not what Firefox does 
(that's the easiest browser to get the DOM source from), but I don't 
think the defined behaviour should be affected by the results of current 
browsers, in this case.

> <!DOCTYPE html>
> <html><head><title>...</title>
> <section>...</section>
> </head><body><div>...</div></body></html>

Firefox doesn't even get that, it does this:
(I've replaced "..." with "section" and "div", respectively, and 
formatted for easier reading)

<html>
   <head>
     <title>Testing</title>
     <section></section>
   </head>
   <body>
     section
     <div>
       div
     </div>
   </body>
</html>

In fact, even if you explicitly insert the <body> start tag, you get 
some strange results from unknown elements like section.  For example, 
given this document:

<!DOCTYPE html>
<title>Testing</title>
<body>
<section>section
   <em>emphasis</em>
   <article>article</article>
   <div>div</div>
</section>

Firefox closes the section element before any known block element, but 
allows any text nodes, inline elements, and other unknown elements to be 
nested.

<html>
   <head>
     <title>Testing</title>
   </head>
   <body>
     <section>
       section <em>emphasis</em>
       <article>article</article>
     </section>
     <div>
       div
     </div>
   </body>
</html>

This is why it should be defined that elements like <setion> should 
imply <body>; however, for backwards compatibility, it should be 
recommended that the start tags not be omitted in such cases.  Even 
then, it won't always work as intended.  eg. you can't use these:

   section div, section p, ... { /* ... */ }

-- 
Lachlan Hunt
http://lachy.id.au/




More information about the whatwg mailing list