|
Posted by John Hosking on 08/24/07 15:34
X Ryl wrote:
>
> I've tried validate something like (declaration excluded) :
Don't you think that's important?
> <h1>foo <div>bar</div></h1>
>
> It doesn't validate, as <h1>'s DTD is : <!ELEMENT (%heading;) - -
> (%inline;)* -- heading -->
> meaning that h1 can only contains inline element.
Right; what's *inside* a <h1> must be inline.
>
> That's strange as DIV DTD is : <!ELEMENT DIV - - (%flow;)*
> -- generic language/style container -->
> with flow being "block or inline"
Not strange; this means that what's *inside* a <div> is block or inline.
But the element itself is block-level. Therefore no good inside a <h1>.
>
> That's also strange as the same code with p in-place of h1 validate:
> <p>foo <div>bar</div></p>
Because the closing tag for <p> is optional, a browser can (and I
believe most do, but I've forgotten the exception(s)) terminate the p
element when it hits the <div>. When it gets to the coded </p> tag, it
then has to decide what to do about it. I believe most (all?) browsers
ignore it silently as a harmless coding error.
We just had a discussion about this here (or hereabouts) roughly 3 to 5
months ago.
See also http://www.w3.org/TR/html401/struct/global.html#h-7.5.4 if you
haven't already.
> and P DTD ( <!ELEMENT P - O (%inline;)* -- paragraph --> )
> is declared like H1
Not exactly. H1 is declared as
<!ELEMENT (%heading;) - - (%inline;)* -- heading -->
so the closing tag </h1> is required.
>
> Also, both P and H1 are declared in block level elements.
I'm not sure what you mean by this sentence.
>
> What is the reason behind this ?
> Does DIV transmutate to inline only in P or is there a rule for this ?
No, yes, see above.
--
John
Pondering the value of the UIP: http://blinkynet.net/comp/uip5.html
Navigation:
[Reply to this message]
|