Reputation: 1471
Here's the HTML,
<body class="home page page-id-13">
<div class="targetthis">
</div>
</body>
I want to target the class "targetthis" only when the body class has both "home" and "page" on it.
Upvotes: 0
Views: 42
Reputation: 98
You could just write firstClass.secondClass.thirdClass .childNodeClass
https://css-tricks.com/multiple-class-id-selectors/
Upvotes: 1
Reputation: 13988
Use both the classes in your target CSS selector like below.
body.home.page .targetthis
{
background-color:red;
}
Upvotes: 1
Reputation: 58422
Try this
body.home.page .targetthis
by removing the spaces you are saying that you want an element with both classes, and by using the body, you are saying you are wanting the body element with both classes
If you only want targetthis
as the direct child then you need to add the >
More info on multiple class / id selectors
Upvotes: 4