Weird validation result

Weird validation result

am 24.08.2007 16:55:59 von X Ryl

Hi,

I've tried validate something like (declaration excluded) :

foo
bar



It doesn't validate, as

's DTD is : (%inline;)* -- heading -->
meaning that h1 can only contains inline element.

That's strange as DIV DTD is : -- generic language/style container -->
with flow being "block or inline"

That's also strange as the same code with p in-place of h1 validate:

foo

bar


and P DTD ( )
is declared like H1

Also, both P and H1 are declared in block level elements.

What is the reason behind this ?
Does DIV transmutate to inline only in P or is there a rule for this ?

Best regards

Re: Weird validation result

am 24.08.2007 17:27:25 von Harlan Messinger

X Ryl wrote:
> Hi,
>
> I've tried validate something like (declaration excluded) :
>

foo
bar


>
> It doesn't validate, as

's DTD is : > (%inline;)* -- heading -->
> meaning that h1 can only contains inline element.
>
> That's strange as DIV DTD is : > -- generic language/style container -->
> with flow being "block or inline"

Right, but that's irrelevant to what's happening with your code.

>
> That's also strange as the same code with p in-place of h1 validate:
>

foo

bar


> and P DTD ( )
> is declared like H1

The difference is that H1 has "- -" and P has "- O". The end tag is
optional for P, which means that the user agent closes the P element
automatically as soon as it encounters the beginning of another element
that can't be nested inside or the end of an element within which the P
element is nested. In your example, the validator deems the P to be
closed as soon as it encounters the start tag for the DIV, and it
interprets the two elements as a P element *followed by* a DIV element,
not as a P element *containing* a DIV element. However, the validator
will also flag the closing

as an error because no P element is open
at that point. Did you notice that?

The H1 end tag isn't optional, and since you haven't explicitly closed
the H1 element at the point where the DIV begins, the validator treats
your code is nesting a DIV inside the H1, which isn't allowed.

>
> Also, both P and H1 are declared in block level elements.

This has no bearing on what they can or can't contain.

Re: Weird validation result

am 24.08.2007 17:34:16 von John Hosking

X Ryl wrote:
>
> I've tried validate something like (declaration excluded) :

Don't you think that's important?

>

foo
bar


>
> It doesn't validate, as

's DTD is : > (%inline;)* -- heading -->
> meaning that h1 can only contains inline element.

Right; what's *inside* a

must be inline.

>
> That's strange as DIV DTD is : > -- generic language/style container -->
> with flow being "block or inline"

Not strange; this means that what's *inside* a
is block or inline.
But the element itself is block-level. Therefore no good inside a

.

>
> That's also strange as the same code with p in-place of h1 validate:
>

foo

bar



Because the closing tag for

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

. When it gets to the coded

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 ( )
> is declared like H1

Not exactly. H1 is declared as

so the closing tag

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

Re: Weird validation result

am 24.08.2007 17:35:38 von Andy Dingley

On 24 Aug, 15:55, X Ryl wrote:

> I've tried validate something like (declaration excluded) :
>

foo
bar


>
> It doesn't validate, as

's DTD is : > (%inline;)* -- heading -->
> meaning that h1 can only contains inline element.
>
> That's strange as DIV DTD is : > -- generic language/style container -->
> with flow being "block or inline"

That means that
can _contain_ "block or inline"

itself is a member of %block;, but _not_ a member of %inline;
and so it can't be placed inside


You need to read the definition of %block; to see this, not the
definition of

Re: Weird validation result

am 24.08.2007 17:44:26 von X Ryl

On 24 ao=FBt, 17:35, Andy Dingley wrote:
> On 24 Aug, 15:55, X Ryl wrote:
>
> > I've tried validate something like (declaration excluded) :
> >

foo
bar


>
> > It doesn't validate, as

's DTD is : > > (%inline;)* -- heading -->
> > meaning that h1 can only contains inline element.
>
> > That's strange as DIV DTD is : > > -- generic language/style container -->
> > with flow being "block or inline"
>
> That means that
can _contain_ "block or inline"
>
>
itself is a member of %block;, but _not_ a member of %inline;
> and so it can't be placed inside


> You need to read the definition of %block; to see this, not the
> definition of


Thank you, all of you, for your answers. It's clear now.
It's not obvious when default browser behaviour hides what should be
seen as error.