I'm trying to theme some buttons according to their ancestors (not parents, especialy), so... I have the following HTML structure
<body class="theme-a"> <section class="container"> <form class="theme-b"> <div class="button-group"> <button type="button">Button B1</button> <button type="button">Button B2</button> </div> <div class="button-group"> <button type="button">Button B3</button> <button type="button">Button B4</button> </div> </form> <form> <div class="button-group"> <button type="button">Button A1</button> <button type="button">Button A2</button> </div> <div class="button-group"> <button type="button">Button A3</button> <button type="button">Button A4</button> </div> </form> </section> </body> Well, as you can see, there are two themes .theme-a and .theme-b
The CSS code, looks like:
.theme-a { background: #999; } .theme-b { background: #555; } .theme-a button { background: #222; } .theme-b button { background: #69C; } The problem is: if you switch the theme classes (A with B and B with A), you'll notice that the button on A theme (which has a closer ancestor with the theme class, keeps the styling of the far ancestor, the blue background rather than black one).
How can I achieve a proper specificity in a way that the button properties are set according to the closest ancestor?
Here's the link from JSfiddle: http://jsfiddle.net/XVaQT/1/
I hope that I explained in a clear way :)
Thanks
E Fis equally specific toE > F.