Firstly, lets deal with the markup. I believe that the <col>
should be self-closing as it cannot contain any text or child elements and also it should be wrapped in a <colgroup>
. You may even need additional <col>
tags for each column (so 4 columns means 4 <col>
's).
<table>
<colgroup>
<col class="col1" />
<col />
</colgroup>
<tr class="row_odd"><td>test</td><td>test</td></tr>
<tr class="row_even"><td>test</td><td>test</td></tr>
</table>
Now, having had a little play about with the CSS, it seems it's down to how CSS is applied to columns and <tr>
's. If you remove the styles pertaining to the <tr>
's you will see that the style is applied correctly.
So from this i have concluded that the styles are applied in a layered approach, probably because of the columns being a kind of meta detail of tables. An easy way to imagine this is that the <tr>
tags are layered on top of the column, and because you've defined a background-color
for the <tr>
the column styling does not show through - due to the colour being opaque. If you set the <tr>
's background-color
to an RGBA value you will see that the columns colour "shines through".
See the modification of your fiddle, for demonstration: http://jsfiddle.net/uqJHf/4/
Hope that helps, it certainly helped me because i've learnt something new here myself during my investigation.
EDIT: seems that IE9 doesn't agree with what i said, it doesn't seem to apply the RGBA value to the <tr>
if the <col>
has a background-color
set. Works in firefox 7 though...