David Stockdale's Scrapcode

CSS Targeting Specific Child

This post is more to remind myself of all the tricks you can do with “nth-child” than anything else.

The most simple use of it is to target a specific child class:


Then there is the possibility of targeting the nth child of every class within something:


Or narrow it down to images found within only the 2nd child of any class of a specific type (in this example “p” class) within something.


Here’s what I was fiddling with when I decided to make this post:

#jetpack_display_posts_widget-3 .jetpack-display-remote-posts>p:nth-child(8)>img

Leave a Reply