Forum Moderators: open
please have a look at the following code and explain me why it is not W3 HTML Transitional 4.01 compliant!
<p><ol id="css">
<li>text</li>
<li>text</li>
<li>text</li>
<li>text</li>
<li>text</li>
</ol></p>
DOC TYPE is HTML Transitional 4.01 (loose), everything except for that piece of code validates. The HTML Validator marks </p>, saying it would be an end tag for an element that is not open.
What's wrong?
Lupi
When a list is openend (with dl, ol, ul and so on) then that open element will close any previous paragraph that is still open. Because a </p> is optional and could have omitted, the parser will just assume a </p> before the <ol> and that makes the </p> after the </ol> "extra".
So you don't need the <p> in this case.
Technically the <p> is a block level element, as it creates an element which displays as a block, but that particular block element can can only contain *inline* elements [w3.org].
<!ELEMENT P - O (%inline;)* -- paragraph -->
<!ATTLIST P
%attrs; -- %coreattrs, %i18n, %events --
>
A list ~ OL, UL, DL ~ is (in my books anyway) a block level element ~ but it is technically defined as a list element which may not be helpful in in it's own right, but the children (descendants) of these list elements <li> [w3.org] and <dd> [w3.org] are defined as flow [w3.org] elements which means they can contain either block [w3.org] or inline [w3.org] elements ..
phew.. that means that the <p> cannot (validly) contain a list because if any particular <li> or <dd> were to contain a block level element as it's "validly allowed to" the <p> validation rule is broken, which is what is happening..
Suzy
Neither the CSS validator nor the HTML validator will see an error, but in the combination between the two, might I cause some browser, some day, to have a problem?