W3C home > Mailing lists > Public > www-validator-css@w3.org > July 2002

Bug in CSS Validator? p inside td not allowed in HTML 4.01

From: Thomas Luethi <pubtom@bigfoot.com>
Date: Sat, 6 Jul 2002 16:32:53 -0400 (EDT)
Message-Id: <200207062032.g66KWou18680@smtp.swissonline.ch>
To: www-validator-css@w3.org




Summary of this posting: 
For a HTML 4.01 Strict document with the following CSS rule:
td p { border:1px dashed #FF9800; margin:1px; }
the CSS Validator gives the warning message:
"p can't be inside an inline element"
The same rule is validated without a warning when the document is XHTML 1.0 Strict.

According to my understanding of the Specifications and DTDs of both HTML 4.01 and XHTML 1.0, it is 
valid to have block-level elements (such as P, H1, H2, ...) within table cell elements (TH, TD).

I therefore think that this warning of the CSS Validator is a bug.

---

I have a document [1] in HTML 4.01 Strict. It contains a table.
Within the table cells (TD elements), I use H2 and P elements.
<table>
 <tr><td><h2>...</h2><p>...</p></td></tr>
 <tr><td><h2>...</h2><p>...</p></td></tr>
</table>

In order to style these H2 and P elements, I use a STYLE element with "descendant" rules within the 
HEAD of the HTML Document:

<style type="text/css">
td p  { border:1px dashed #FF9800; margin:1px; }
td h2 { border:1px dashed #98FF98; margin:1px; /* plus more */}
</style>

So far, so good. 
The W3C's (X)HTML-Validator confirms [2] that it's valid HTML 4.01 Strict.
The browsers show the document the way I want.

However, the CSS-Validator gives two warnings [3]:
Line:13  p can't be inside an inline element
Line:14  h2 can't be inside an inline element

The HTML 4.01 Strict DTD [4] says that TH and TD Elements may contain "%FLOW" type elements:
<!ELEMENT (TH|TD)  - O (%flow;)*  -- table header cell, table data cell-->

In the same DTD, %FLOW is described as:
<!ENTITY % flow "%block; | %inline;">

Plus, the HTML 4.01-Specification [5] contains the following phrase:
| An attribute set on an element within a cell's data (e.g., P).

Thus, I think that in HTML 4.01, TD elements are clearly allowed to contain P and H2 elements, as 
well as other block-level elements.


I then converted my document into an XHTML 1.0 Strict document [6].
For this document, the CSS Validator does _not_ give any warnings.

The XHTML 1.0 Strict DTD [7] says that TD elements may contain "%FLOW" type elements:
<!ELEMENT td       %Flow;>

It describes "%FLOW" as a mix of Block-Level and Inline elements:
<!ENTITY % Block "(%block; | form | %misc;)*"> 
<!-- %Flow; mixes Block and Inline and is used for list items etc. -->
<!ENTITY % Flow "(#PCDATA | %block; | form | %inline; | %misc;)*">


I therefore think that there is no real difference between XHTML 1.0 and HTML 4.01 for this issue, 
and that in both HTML versions, a TD element may contain block-level elements, for example P, H1, 
and H2 elements.


In the CSS Level 1 or Level 2 Specifications, I did not find any statement defining the TD element 
to be an inline-level element.

Even if the CSS Specifications would define the TD element to be an inline-element, or if for some 
other reason (according to CSS "laws") a TD element would not be allowed to contain block-level 
elements, it wouldn't make sense to me that the CSS Validator only gives the warnings when the 
document is HTML 4.01 and not when it is XHTML 1.0.


To conclude, I think that the CSS Validator's error message "p can't be inside an inline element"
(where "inline element" means the TD element) is a bug.

Please check it out and - if necessary - fix it.

Thank you, kind regards,

Thomas Luethi
Berne, Switzerland

[1] <http://www.tiptom.ch/tests/css/lineheight.html>
[2] <http://validator.w3.org/check?uri=http://www.tiptom.ch/tests/css/lineheight.html>
[3] 
<http://jigsaw.w3.org/css-validator/validator?uri=http://www.tiptom.ch/tests/css/lineheight.html>
[4] <http://www.w3.org/TR/html401/sgml/dtd.html>
[5] <http://www.w3.org/TR/html401/struct/tables.html#h-11.3.2.1>
[6] <http://www.tiptom.ch/tests/css/lineheight2.html>
[7] <http://www.w3.org/TR/2000/REC-xhtml1-20000126/DTD/xhtml1-strict.dtd>
Received on Thursday, 11 July 2002 18:09:50 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Wednesday, 27 June 2012 00:14:11 GMT