CSS Selector/Target for Div Element with Multiple Classes
Overview
There may be times when you need to add a custom attribute to a div element that has multiple classes assigned such as:
<div class="class1 class2">Need to target this div</div>
But you may be wondering how to write a new css selector to only target the elements that have both of those same classes as an attribute.
Solution
Just write the classes together without a space…
.class1.class2{background: #ccc;}








Additionally, the selectors don’t need to be in the same order as they are in the element’s class attribute.
.class2.class1 {…} will work in exactly the same way.
[Reply]
Thanks for adding the additional insight Ryan
[Reply]