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

On Wed, 6 Apr 2005, Lachlan Hunt wrote:
> > >
> > > <script type="text/javascript" src="bar"></script>
> > > <title>Foo</title>
> > > 
> > > ..?
> > 
> > If I am not mistaken:
> > 
> >    <html><head><script.../>
> >    <title.../></head><body></body></html>
> 
> I believe you are mistaken.  A conforming SGML parser will not imply the 
> body element without any content to make it do so.

I meant in existing UAs, not in the spec. According to the HTML spec, the 
handling of the above is completely undefined since it is invalid. (Note 
that something being invalid or non-conformant does _not_ make the 
rendering undefined in most cases in Web Apps 1 / HTML5. That's one of the 
main things I'm making sure of.)


> > > 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>
> > 
> > The <body> will always be implied, though.
> 
> Not in a conforming SGML parser, though it seems to be in Mozilla, Opera and
> IE, as I checked using your DOM viewer [1].

Yeah, I meant in browsers, not per SGML.


> However, if the <body> element were to be automatically implied 
> regardless, then the same would be true of the <tbody> element since 
> both are required elements of <html> and <table>, respectively, and both 
> have optional start- and end-tags,the rules for both must be the same. 
> Neither Mozilla or Opera implies the missing tbody element within 
> <table></table>, although IE does. However, OpenSP does not imply the 
> missing elements in either case.

<tbody> is implied if there is a <tr> there.

The history behind all these quirks is long and confused. <body> in 
particular has had an especially colourful past.


> > (For backwards compatibility with legacy parsers, the <head> probably 
> > won't be.)
> 
> The head element seems to be implied by Mozilla and IE.

Even when there are no elements that imply a <head>? I meant, e.g., when 
parsing the empty string as HTML. My understanding was that no <head> 
element was generated in that case.


> Opera and OpenSP correctly don't imply the missing head element.

I'm not sure what you mean by "correctly" here since an HTML4 document 
without a <title> is invalid and thus parsing is undefined in HTML4. If 
there is a <title> then the <head> must be implied per SGML.

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

Received on Tuesday, 5 April 2005 10:12:00 UTC