W3C home > Mailing lists > Public > whatwg@whatwg.org > June 2010

[whatwg] 'Main Part of the Content' Idiom

From: Aryeh Gregor <Simetrical+w3c@gmail.com>
Date: Fri, 4 Jun 2010 17:24:13 -0400
Message-ID: <AANLkTinZEDxBpd4EBY4j0L6ftN4JdGdLleO1T2ZDu_2t@mail.gmail.com>
On Fri, Jun 4, 2010 at 4:03 PM, Tab Atkins Jr. <jackalmage at gmail.com> wrote:
> No browser depends on you using the <body> element explicitly. ?It's
> perfectly fine to write your document like this:
>
> <!doctype html>
> <title>Test</title>
> <style>
> ?aside {border:1px solid #bf0000;white-space:nowrap;}
> </style>
> <aside>
> ?Just testing aside outside body!
> </aside>
> <article>
> ?Main part of article.
> </article>

It's unwise to omit <body> unless you can guarantee that the first
element in the body will actually trigger the end of the head.  In
your case, I believe that at least IE will put <aside> and <article>
in the head, because it doesn't recognize them as only belonging in
the body.  (It seems like the HTML5 parser does put it in the body --
although as far as I can tell, this means we can never introduce new
elements that can go in the head.)

On Fri, Jun 4, 2010 at 4:36 PM, bjartur <svartman95 at gmail.com> wrote:
> As I understand it the opening and closing tags of the <html>, <head> and
> <body> elements are optional so that whenever content that belongs in
> one of those elements (such as text) is encountered it's automatically
> opened. Same as <p> elements get closed when block content is encountered
> (in HTML 4 that is). This is fully specified and documented and is in the
> DTD.
>
> This is valid HTML 4.
>
> is in fact a valid HTML file with an empty <head>.

Something seems to have been left out of your e-mail, but anyway, a
valid HTML file cannot have an empty <head>.  All HTML documents must
have a <title> element, which must be contained in a <head>.  This was
true in HTML 4.01 just as it is in HTML5.
Received on Friday, 4 June 2010 14:24:13 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:24 UTC