Reputation: 333
How to select child element after some position? For example:
<ul>
<li>first</li>
<li>second</li>
<li>third</li>
<li>fourth</li>
<li>fifth</li>
<li>sixth</li>
<li>seventh</li>
</ul>
I want to select all li
item escaping first, second and third.
Upvotes: 1
Views: 649
Reputation: 46795
Use the nth-child
selector with the appropriate offset.
n
takes on values starting with 0, 1, 2... so this will select the 4th, 5th, 6th ... child elements of the ul
.
li:nth-child(n+4) {
color: red;
}
<ul>
<li>first</li>
<li>second</li>
<li>third</li>
<li>fourth</li>
<li>fifth</li>
<li>sixth</li>
<li>seventh</li>
</ul>
Upvotes: 5