[FAQ] Common Problems #Read Me

The general HTML & CSS FAQ can be found here.

This FAQ is for 9. CSS Selectors.


###Pseudo Selectors
Many people struggle with using Pseudo Selectors, this helps to clarify their usage, written by @mtf @zainabrawat


We hope these common problems will help all of you with your coding.
If you see any questions in this category that can be answered by this FAQ, please link the user over here.

Thanks,
The Codecademy Moderators


If we see a brilliant post worthy of being added to this or any other FAQ we will send you a PM to ask you to repost your answer in one of the FAQs.

This topic is not for questions, if your problem is still not answered after reading through all these Common Problem then please create a new topic.

##Discussion: Pseudo Selector
HTML & CSS - CSS Selectors - Lesson 23 Pseudo Selector

Pseudo selector is a bit tricky so here’s an explanation on it to help you understand better.


In the pseudo selector white space makes a difference. Examples:

p:nth-child(4) /* no white space between p and : */

This will target the p element which is a fourth child of its parent element.

p :nth-child(4)    /* with white space */

This will target the fourth child (of any tag name) of a p element.

Also note the following selector:

:nth-child(4)        /* yes, this is legitimate */

This will target an element (of any tagname) that is the fourth child of its parent element. Either of the above two will work in your case.


This explanation was derived from this topic and thanks to @mtf who explained it.

Read more: