Reputation: 2643
Is it possible with CSS3 to select an element that comes right after another? If I have, for example:
<div>
<a class="a">One</a>
<a class="b">Two</a>
<a class="c">Three</a>
<a class="b">Four</a>
</div>
I want to select the class="b" anchor that comes after the class="a" anchor only. So I'd want the "Two" anchor selected and not the "Four" anchor.
Is that possible in CSS3? If not, is it possible in jQuery? (though, I'd prefer CSS).
Upvotes: 1
Views: 472
Reputation: 46208
You don't need CSS 3 for this, it was already possible in CSS 2.1! :)
Use the adjacent sibling selector +
:
.a + .b {
/* styles */
}
Upvotes: 5