Reputation: 15648
Suppose I have a few classes applied to a div like this:
<div class="classA classB classC">...</div>
In my CSS, I want to target and write styles for those classC
that have classB
applied to the same div as well.
If I use this:
.classB .classC {...}
This will only work if there is another child div, and is not what I want.
So, how can I target those classC
that has classB
applied to the same div?
Upvotes: 0
Views: 83
Reputation: 28437
You can stack them. Like so.
div.classA.classB.classC
This would work with IDs too, even though it is less applicable.
div#unique-1.classA.classB
Upvotes: 1
Reputation: 2409
Like this:
.classB.classC { }
No spaces between the classes will target all elements with both.
Upvotes: 1