HighDots Forums  

question about the BODY tag in the HTML DTD

HTML Writing HTML for the Web (comp.infosystems.www.authoring.html)


Discuss question about the BODY tag in the HTML DTD in the HTML forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Bart Lateur
 
Posts: n/a

Default question about the BODY tag in the HTML DTD - 04-08-2008 , 02:36 PM






In the DTD of HTML 4.01, <http://www.w3.org/TR/html401/sgml/dtd.html>,
it states that the only legal elements in the BODY element are block
tags (and a few more: SCRIPT, INS and DEL):

<!ELEMENT BODY O O (%block;|SCRIPT)+ +(INS|DEL) -- document body -->

These block elements are the following:

<!ENTITY % block
"P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS">

Where %heading; is the tags H1 to H6, %list; is UL and OL, and
%preformatted; is PRE.

That is all.

So, if I get this correctly, it is not legal to put text, or inline
elements (text formatting, SPAN) directly into a BODY tag. None of these
tags are implied. Yet, people do it all the time.

What gives? Am I misunderstanding the spec, or a people doing it wrong?

--
Bart.

Reply With Quote
  #2  
Old   
Joost Diepenmaat
 
Posts: n/a

Default Re: question about the BODY tag in the HTML DTD - 04-08-2008 , 03:08 PM






Bart Lateur <bart.lateur (AT) pandora (DOT) be> writes:

Quote:
So, if I get this correctly, it is not legal to put text, or inline
elements (text formatting, SPAN) directly into a BODY tag.
I'm too lazy to check, but that's my recollection too. Also, IIRC the
w3c HTML validator will warn on these cases.

Quote:
None of these tags are implied. Yet, people do it all the time.

What gives? Am I misunderstanding the spec, or a people doing it wrong?
People are doing it wrong. But since it mostly works, they'll keep on
doing it. This also goes for all the other places where non-blocks
aren't allowed.

--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/


Reply With Quote
  #3  
Old   
Harlan Messinger
 
Posts: n/a

Default Re: question about the BODY tag in the HTML DTD - 04-08-2008 , 03:15 PM



Bart Lateur wrote:
Quote:
In the DTD of HTML 4.01, <http://www.w3.org/TR/html401/sgml/dtd.html>,
it states that the only legal elements in the BODY element are block
tags (and a few more: SCRIPT, INS and DEL):

!ELEMENT BODY O O (%block;|SCRIPT)+ +(INS|DEL) -- document body --

These block elements are the following:

!ENTITY % block
"P | %heading; | %list; | %preformatted; | DL | DIV | NOSCRIPT |
BLOCKQUOTE | FORM | HR | TABLE | FIELDSET | ADDRESS"

Where %heading; is the tags H1 to H6, %list; is UL and OL, and
%preformatted; is PRE.

That is all.

So, if I get this correctly, it is not legal to put text, or inline
elements (text formatting, SPAN) directly into a BODY tag. None of these
tags are implied. Yet, people do it all the time.
People also exceed the speed limit and fail to declare gambling winnings
to the tax authorities.

Quote:
What gives? Am I misunderstanding the spec, or a people doing it wrong?
In earlier HTML it was OK, and it's still OK in HTML 4.01 Transitional,
but not in Strict.


Reply With Quote
  #4  
Old   
Nick Theodorakis
 
Posts: n/a

Default Re: question about the BODY tag in the HTML DTD - 04-08-2008 , 03:21 PM



Bart Lateur wrote:
Quote:
In the DTD of HTML 4.01, <http://www.w3.org/TR/html401/sgml/dtd.html>,
it states that the only legal elements in the BODY element are block
tags (and a few more: SCRIPT, INS and DEL):
[...]

Quote:
So, if I get this correctly, it is not legal to put text, or inline
elements (text formatting, SPAN) directly into a BODY tag. None of these
tags are implied. Yet, people do it all the time.

What gives? Am I misunderstanding the spec, or a people doing it wrong?

People are either doing it wrong, or else using a transitional doctype
where it is allowed.

Nick


--
Nick Theodorakis
nick_theodorakis (AT) hotmail (DOT) com
contact form:
http://theodorakis.net/contact.html


Reply With Quote
  #5  
Old   
Andy Dingley
 
Posts: n/a

Default Re: question about the BODY tag in the HTML DTD - 04-09-2008 , 05:34 AM



On 8 Apr, 20:36, Bart Lateur <bart.lat... (AT) pandora (DOT) be> wrote:

Quote:
What gives? Am I misunderstanding the spec, or a people doing it wrong?
This is correct (but just for 4 Strict, not 3.2 or Transitional) and
most coders do indeed use it wrongly.

The intention is a clear and simple one, if only you're aware of it.
%inline; elements are considered to be "bare" and without well-managed
container boxes, so shouldn't be placed naked onto a page.

You can even extend this attitude so that %inline; content shouldn't
be used in a %block; context in general. This isn't expressed in the
DTD, because most contexts accept %flow; rather than %block; alone.
However mixing inline and block elements as siblings is not a
recommended practice, certainly not at the higher scale of the DOM.

As a specific example, I often float <div> around on a page (image/
caption containers) to avoid the rigid grid look of simple CSS
layouts. It's also necessary to place a HTML element after these with
clear used to tidy up after the floating. I used to use a <br> for
this. That worked fine, and because they were all contained in overall
<div> anyway, it was even valid. However I now regard it as
inappropriate, so I use <hr> instead (with some CSS to make the usual
horizontal rule disappear).


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.