First, none of your selectors are applied. The first and third one aren't because main-content
is a class, so you have to use .main-content
.
The second one isn't applyed to your element because you added a space between .main-content
and .wf100
wich means :
element with wf100
class inside a main-content
element.
Without the the space (.main-content.wf100
) you specify :
elements with main-content
and wf100
classes.
Now your selector is correct, it still doesn't work. Why ? because inline css has the highest priority after !important
property that you need to use here.
Because !important
has the highest priority, you can apply it to .main-content.wf100
but also .main-content
or .wf100
.
/* wrong selector */
.main-content .wf100{
background-color:green;
}
/* correct selector, but not enough priority */
.main-content.wf100{
background-color:green;
}
.main-content.second-content{
background-color:orange!important;
}
.another-content{
background-color:yellow!important;
}
<div class="main-content wf100 "style="background-color:#172132;color:white;">wf100</div>
<br>
<div class="main-content second-content" style="background-color:red;">second content</div>
<br>
<div class="main-content another-content" style="background-color:red;">another content</div>
<br>
<div class="another-content" style="background-color:red;">another content without .main-content</div>