How can I use :first-child
with :not(.ignore)
in order to select every element that is the first child of its parent, unless that first child is of class ignore
?
What I've tried: :first-child:not(.ignore){...}
,:first-child :not(.ignore){...}
, I've also came across this answer, which is phrased as if it was what I am looking for, however the person asking didn't seem to understand how the :first-child
selector works. Apart from that, one of the answers suggests that :first-child:not(.ignore){...}
should work exactly as I expect it to, but for me it just doesn't.
My question is: Am I missing something with syntax or it is just not possible to combine selectors in this way?
:first-child:not(.ingore){
background-color:lightblue;
}
<body >
<div>
<div>
should be blue and is blue
</div>
<div>
should also be blue as it's parent is blue due to being first child of 'body'
</div>
</div>
<div>
<div class="ignore">
should not be blue but is blue
</div>
<div>
should not be blue and is not blue
</div>
</div>
</body>