Selecting the second occurrence of a class with CSS?
css
Solution
You can use this with selectors level 3 to select those that aren't the first one :
.orange ~ .orange {
}
Demonstration
The best is to complete the style with a rule describing the other `.orange` elements :
.orange, .orange ~ .orange ~ .orange {
}
Demonstration
Problem
Given the following (dynamic) markup, I need to match the second occurrence of the class orange, regardless of how many divs have the class apple. ``` <div> <div class="apple"></div> <div class="apple"></div> <div class="orange"></div> <div class="apple"></div> <div class="apple"></div> <div class="orange"></div> <-- <div class="apple"></div> </div> ``` Can it be done with CSS? Thanks.