I would liky to select single div with specific class using only-child pseudo selector. I was hoping something like this would work.
.foo .bar:only-child {
background-color: red;
}
<div class="foo">
<div>1</div>
<div class="bar">2</div>
<div>3</div>
</div>
but this does not work, does it work with classes or only with types?
Solution:
Ok so I finally found the solution but since this is marked as duplicate (which I don't think it is) I will post it here
.foo bar:only-of-type {
background-color: red;
}
<div class="foo">
<div>1</div>
<bar>2</bar>
<div>3</div>
</div>