I had a brief look at the CSS3 Selectors spec but couldn't find anything how to get round this problem. Additionally, I wasn't expecting the result from this to change when you move the CSS declarations around but it does. Any help would be great.
div.green_colour div.has_colour{ background-color: green; } div.red_colour div.has_colour{ background-color: red; } <div class="red_colour"> <div class="green_colour"> <div class="has_colour"> I would like this to be green </div> </div> </div> <div class="green_colour"> <div class="red_colour"> <div class="has_colour"> I would like this to be red </div> </div> </div>