You are here: Re: Weird validation result « HTML « IT news, forums, messages
Re: Weird validation result

Posted by Harlan Messinger on 08/24/07 15:27

X Ryl wrote:
> Hi,
>
> I've tried validate something like (declaration excluded) :
> <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.
>
> That's strange as DIV DTD is : <!ELEMENT DIV - - (%flow;)*
> -- 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:
> <p>foo <div>bar</div></p>
> and P DTD ( <!ELEMENT P - O (%inline;)* -- paragraph --> )
> 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 </p> 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.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация