CSS - How to select everything except the first element

Problem

If you have a <ul> (unordered list) and want to apply some style to all child <li> elements except for the first li. You want to do this all in pure CSS, without using JavaScript

Solution

ul li:nth-child(n+2) { // stuff here }

Explaination

The :nth-child is a new selector. The arguments are hard to understand. The "n" means apply this to every element, the "+2" means "start at the 2nd element"

Related Links

This entry is tagged: