I have the following markup:
<div class="a"></div>
<div class="b"></div> <!-- :first -->
<div class="b"></div>
<div class="b"></div> <!-- :last -->
<div class="c"></div>
I'm trying to target the first and last <div>
with class b
.
If I was using jQuery selectors for this, .b:first
and .b:last
would do the trick.
However with CSS, that's tricky: the first <div class="b">
is located after another <div>
with a different class, and both :first-child and :first-of-type match the first <div>
, with class a
.
Is there a selector targeting the first of the items matching the class?