I'm using plain CSS, making tables. I want every odd row in a table highlighted to make it easier to read. But I want different tables to be of different colors.
It would seem this should work:
CSS file:
.redtable.odd {background-color:red;}
.yellowtable.odd {background-color: yellow;}
HTML file:
<table class="redtable">
<tr class="odd"><td>row</td><td>1</td></tr>
<tr><td>row</td><td>2</td></tr>
<tr class="odd"><td>row</td><td>3</td></tr>
</table>
<table class="yellowtable">
<tr class="odd"><td>row</td><td>1</td></tr>
<tr><td>row</td><td>2</td></tr>
<tr class="odd"><td>row</td><td>3</td></tr>
</table>
But the <tr> tags don't seem to know that they're of class redtable or yellowtable. Isn't the "C" of "CSS" supposed to mean "Cascading"? Shouldn't these nested tags inherit classes?
(I'd really rather not have to add the explicit class to every single <tr>. The real tables are hundreds of rows long.)
JSFiddle link: https://jsfiddle.net/tr0moyo0/
Thanks.