My code is not working. It should work when the checkbox is checked or unchecked. How could I get this code to change the background color of all cells which class is "name1"? CSS code: .player1-checkbox ~ td.name1 { background-color: blue; } .player1-checkbox:checked ~ td.name1 { background-color: orange; } Code (CSS): HTML code: <input type="checkbox" id="player1" class="player1-checkbox" /> <table class="chart"> <tr><td class="name">Ny Name</td><tr> <tr><td class="name name1"><label for="player1">FIRST LAST</label></td></tr> <tr><td> </td></tr> <tr><td class="cup left name1"><label for="player1">FIRST LAST</label></td> </table> HTML:
Here is the solution... CSS code: .player1-checkbox ~ table tr td.name1 { background-color: blue; } .player1-checkbox:checked ~ table tr td.name1 { background-color: orange; } Code (CSS):
td class="cup left name1" Code (markup): @deathshadow said it best -> "This type of nonsense reaches the pinnacle of stupidity with CSS frameworks or worse, the so called "Object Oriented CSS" (OOCSS). By their very nature they create presentational markup -- if you don't know what's wrong with code like this: <div class="leftCol thirdwidth colorRed sectionHeight bigText"> Code (markup): Do the world a favor and go do something harmless like macramé." Source: http://www.cutcodedown.com/article/whats_wrong_with_YOUR_website_part4
Really the "classes for nothing" are just the tip of the iceberg of problems here... like what in blazes makes a label and a input be tabular data; much less if you only have one TD per TR what the huff are you even using a table FOR?!?