CSS selector with class a but not class b

css, css-selectors

Solution

I believe you can do this with CSS3 using the `:not()` selected (example here)

`div.classa:not(.classb):not(:last-child) {}`

However, as you know, not many browser supports this, so Javascript might be an easier way...

Problem

I've tried all sorts of things but I think i'm getting too complicated and even managed to get chrome to hang with my selector. I'm sure theres a simple way to do this Select `classa` but only when theres no `classb` and ignore the last instance of it ``` <div class="container"> <div class="classa classb"></div> <!-- Dont Select --> <div class="classa"></div> <!-- Select --> <div class="classa"></div> <!-- Dont select last instance --> </div> ```

Original source