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

[whatwg] 'Main Part of the Content' Idiom

From: Ashley Sheridan <ash@ashleysheridan.co.uk>
Date: Fri, 04 Jun 2010 21:32:07 +0100
Message-ID: <1275683527.2217.84.camel@localhost>
On Fri, 2010-06-04 at 13:28 -0700, Tab Atkins Jr. wrote:

> On Fri, Jun 4, 2010 at 1:16 PM, Roger H?gensen <rescator at emsai.net> wrote:
> > On 2010-06-04 22:03, Tab Atkins Jr. wrote:
> >>
> >> On Fri, Jun 4, 2010 at 12:58 PM, Roger H?gensen<rescator at emsai.net>
> >>  wrote:
> >>>
> >>> ...
> >>> As you can see the aside is outside the body, all latest browsers seem to
> >>> handle this pretty fine.
> >>> http://validator.w3.org/ on the other hand gives the error " Line 12,
> >>> Column
> >>> 6: body start tag found but the body element is already open.<body>"
> >>>
> >>> Now, either that is a bug in the validator, or the body is automatic.
> >>> And sure enough, removing the<body>  and</body>  tags the document
> >>> validates, and none of the browsers behave differently at all.
> >>> Is the body tag optional or could even be redundant in HTML5 ?
> >>
> >> <body>  is optional.  It automatically gets added as soon as the parser
> >> sees an element that doesn't belong in the<head>.  (The<head>  is
> >> optional too, as is the<html>.)  So the<aside>  triggers a<body>
> >> element to be created and opened, and then later explicit<body>  tags
> >> get dropped.
> >>>
> >>> I don't mind really, as currently I only use body to put all the "other"
> >>> tags inside, so not having to use the body tag at all would be welcome,
> >>> though I suspect a lot of legacy things rely on the body tag.
> >>
> >> 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>
> >>
> >> The<title>  and<style>  get auto-wrapped in a<head>, the<aside>  and
> >> <article>  get auto-wrapped in a<body>, and the whole thing below the
> >> doctype gets auto-wrapped in an<html>.
> >
> > Hmm! Intriguing. That is way cleaner than the "container" wrappers.
> > What browsers/engines behaves like that?
> > Does all HTML 4.01+ compliant browsers behave like this?
> 
> All browsers that you could possibly care about (any FF, Safari,
> Chrome, Opera, or IE produced in the last decade) should act like
> that.  That's why it got specified - when everyone agrees on behavior,
> it's a good thing to figure that out and standardize it.  ^_^
> 
> ~TJ


And I'm guessing Fx too?

Thanks,
Ash
http://www.ashleysheridan.co.uk


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.whatwg.org/pipermail/whatwg-whatwg.org/attachments/20100604/a4302e9d/attachment-0001.htm>
Received on Friday, 4 June 2010 13:32:07 UTC

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