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

Lachlan Hunt lachlan.hunt at lachy.id.au
Tue Apr 5 03:20:54 PDT 2005

Anne van Kesteren wrote:
> I was wondering if HTML5 (WA1, at the moment) is going to define which 
> tags are optional and which elements are implied. (This is of course 
> only for text/html documents.)
> 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:

>  <script type="text/javascript" src="bar"></script>
>  <title>Foo</title>

Same as above, with the title and script elements swapped.

> ..? Are both part of the implied HEAD element


>  or is the SCRIPT element in the first example perhaps part of the BODY element?


> I believe both are possible.

Both are possible, but since script is allowed within the content of the 
head element, its presence does not imply </head> and <body>.  End tags 
are implied after encountering content which is not allowed within the 

> 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.

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.


Lachlan Hunt
http://GetFirefox.com/     Rediscover the Web
http://GetThunderbird.com/ Reclaim your Inbox

More information about the whatwg mailing list