PDA

View Full Version : TD *without* background, in table *with* background?


robkar97
03-07-2008, 08:38 AM
Consider this CSS...

.cyan {background-color:#00ffff;}
BODY {background-color:#ffff00;}
... applied to this html

<table class="cyan">
<tr>
<th>Header 1</th>
<th>Header 2</th>
</tr>
<tr>
<td>Content</td>
<td>Content</td>
</tr>
</table>

This would render the headers with cyan background, like the entire table. But suppose I wanted the background headers to have a *transparent* background - and not only transparent = showing the table color (=cyan) but transparent as in showing the BODY background (=yellow)?

Can this be done?

Robert

Validus
03-07-2008, 11:15 AM
Just apply the background to the cells themselves, something like this:

table th {
background-color:red;
}

table td {
background-color:blue;
}

robkar97
03-07-2008, 11:22 AM
Hmmm... good point.

However, I was hoping there would be a generic approach since I have lots of generic classes for custom colors used by <table> (eg .bg, .bg-light, .bg-dark).

If possible, it would be nice if all these generic rules had to be duplicated for table tags...:cool:

Robert