- From: Roger Hågensen <rescator@emsai.net>
- Date: Fri, 04 Jun 2010 22:16:38 +0200
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? Roger. -- Roger "Rescator" H?gensen. Freelancer - http://EmSai.net/
Received on Friday, 4 June 2010 13:16:38 UTC