The goal of all the elements next to the first with the nth baby

How to target all paragraphs within a given DIV next to the first using the nth-child operator.

+5
source share
3 answers

You can use the formula:

:nth-child(n+1)

or for some browsers (but W3C says " Using the formula (a + b). Description: a represents the size of the loop, n represents the counter (starts at 0), and b represents the offset value. "):

:nth-child(n+2)

Or you can use a separate CSS declaration :first-childfor this first element.

+8
source

using

p:nth-child(n+2) {
    color: green;   
}

working demo

Reference

+3
source

Try

div > p:nth-child(n+2)

Demo at http://jsfiddle.net/Q6FDq/

+2
source

All Articles