|
|
|
|
||||||
![]() |
|
|
LinkBack | Outils de la discussion |
|
|
#1 (permalink) |
|
Messages: n/a
Hébergeur: |
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. |
|
|
|
#2 (permalink) |
|
Messages: n/a
Hébergeur: |
Bart Lateur <bart.lateur@pandora.be> writes:
> 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. > 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/ |
|
|
|
#3 (permalink) |
|
Messages: n/a
Hébergeur: |
Bart Lateur wrote:
> 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. > 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. |
|
|
|
#4 (permalink) |
|
Messages: n/a
Hébergeur: |
Bart Lateur wrote:
> 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): [...] > > 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@hotmail.com contact form: http://theodorakis.net/contact.html |
|
|
|
#5 (permalink) |
|
Messages: n/a
Hébergeur: |
On 8 Apr, 20:36, Bart Lateur <bart.lat...@pandora.be> wrote:
> 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). |
|
![]() |
| Outils de la discussion | |
|
|