Reputation: 451
Is there a way to apply a background color through CSS at the TR level? I can apply it at the TD level like this:
.my-td{
background-color: #E8E8E8;
background:#E8E8E8;
}
However, the background color doesn't seem to get applied when I attempt to apply the background color at the TR level like this:
.my-tr{
background-color: #E8E8E8;
background:#E8E8E8;
}
Is there a CSS trick to making this work or does CSS not natively support this for some reason?
Upvotes: 0
Views: 67
Reputation: 1587
By default, applying a background color on a table row works.
Here's an example:
.odd {
background-color: pink;
}
.even {
background-color: yellow;
}
<table>
<tr class="odd">
<td>a1</td>
<td>a2</td>
</tr>
<tr class="even">
<td>b1</td>
<td>b2</td>
</tr>
<tr class="odd">
<td>c1</td>
<td>c2</td>
</tr>
<tr class="even">
<td>d1</td>
<td>d2</td>
</tr>
</table>
Something else must be interfering with your colours or there's a particular browser issue that you're encountering if this isn't working for you.
Upvotes: 1