Click to See Complete Forum and Search --> : Setting table background colour


Ash
09-10-2003, 05:14 AM
Hi,

I know that you can use tr { background: #30A2B6; }

to set the colour of a table row, but I need two different coloured rows, one for the table header and one for the rest of the table.

I was hoping I could use something like trtop { background: #30A2B6; }
and
trbottom { background: #586868; }

but I can't get it to work. Where am I going wrong ?

gil davis
09-10-2003, 06:19 AM
There isn't anything "automatic". You can use classes:

<style type="text/css">
tr.top { background: #30A2B6; }
tr.bottom { background: #586868; }
</style>
...
<table>
<tbody>
<tr class="top">
...
</tr>
...
<tr class="bottom">
...
</tr>
</tbody>
</table>

Ash
09-10-2003, 06:23 AM
Star.

Many thanks! :cool:

Charles
09-10-2003, 06:26 AM
You can also break your table up into a THEAD and a TFOOT element separated by any number of TBODY elements. Sort of like DIVs. See http://www.w3.org/TR/html4/struct/tables.html#h-11.2.3.