Take the 2-minute tour ×

Imagine I have a div with a bunch of paragraphs nested inside, I want to select the second, fourth and seventh paragraph element.

I know you can use nth-child to select a nested element, but works for one only. This won't work;


How do I select multiple specific elements. Is this possible?


share|improve this question
Use p:nth-of-type(..), separated by a comma. –  Rob W Aug 20 '12 at 10:33
add comment

2 Answers

How about something like this:

p:nth-child(2), p:nth-child(3), p:nth-child(8)
share|improve this answer
that helps. I realised I could do this. But was wondering if you could select multiple in the same selector but I guess that's not possible. Thanks again. –  user1611477 Aug 20 '12 at 11:13
add comment

read this article i hope this will help you :- http://css-tricks.com/how-nth-child-works/

you can use this method like mentioning below css so this will select every second paragraph.

p:nth-child(2n) {


share|improve this answer
add comment

Your Answer


