Partager via


Are styles illegal on COL elements?

Consider the following HTML: 

IE displays the background color of the second column blue, but Firefox does not. My question for you CSS pros out there is: Is the background-color style not supported on COL elements? (or is there something I can do to make this work?) 

<html>
<body>
<table cellpadding=10>
<colgroup>
<col>
<col style="background-color:#0000FF">
</colgroup>
<tr>
<td>should be window color</td>
<td>should be blue</td>
</tr>
</table>
</body>
</html>

Comments

  • Anonymous
    September 19, 2004
    I've added a DOCTYPE and it now renders fine in Firefox (see url).
  • Anonymous
    September 19, 2004
    Hmm, works with Opera 7 (+ie)
  • Anonymous
    September 19, 2004
    Perhaps the following explanation is not valid for <col> elements, but anyway... Ian 'Hixie' Hickson has explained the "CSS applied to table columns" here: http://ln.hixie.ch/?start=1070385285&count=1
  • Anonymous
    September 19, 2004
    Accually that artical describes why it should work in any css2.1 enabled browser. Just follow the link the the four properties at W3C and there you will read:
    "'background'
    The background properties set the background for cells in the column, but only if both the cell and row have transparent backgrounds. See "Table layers and transparency." "

    That does sum it up, doesn't it?