[whatwg] [html5] tags, elements and generated DOM

On Tue, 5 Apr 2005, Lachlan Hunt wrote:
> >
> > For example, what is the resulting DOM of this document:
> > 
> >  <title>Foo</title>
> >  <script type="text/javascript" src="bar"></script>
> 
> For this, there is no implied body, as there is no element to imply it.  
> SGML rules apply here, as they are expressed in the DTD, and I don't 
> think HTML 5 should change them.  The resulting DOM will be the same as 
> that for an HTML 4 document, which is:
>
> html
> |
> +-head
>   |
>   +-title
>   +-script

HTML5 also causes a <body> to be implied. My understanding actually is 
that in HTML the <body> is required, and so always implied (though it 
cannot be empty, so the document above would be invalid, and technically 
behaviour is undefined by HTML4 and SGML specifications).


> > Is there a BODY element in this document (or, is there always a body
> > element?):
> > 
> >  <style type="text/css">
> >   body{ background:lime }
> >  </style>
> > 
> > ... or this:
> > 
> >  <title>Bar</title>
> 
> No, there is no implied body element in either of those fragments.

In HTML5, there is. In HTML4, it's undefined.


> Run all of your examples through the validator, with the the Show Parse 
> Tree option selected and see for yourself.  The rules for an HTML 5 
> document will be the same as HTML 4.

There are exceptions, mostly for backwards-compatibility reasons, but no 
particularily important ones as far as authors are concerned.


HTH,
-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Thursday, 23 February 2006 18:28:38 UTC