18. Show it if you know it!


#1

I originally wrote:

body: first-child {}

and

body: nth-child() {}

I thought that the <a> element was a child to the body.

I know now that the first-child and nth-child works when there are several identical elements nested in the same place.


#2

if you want to select the first link in body make sure your spacing is right:

body :first-child

or you could use a:first-child to select the first link, just make sure the spacing is right


#3

Hi again,

I thought I understood this but when I did the review question called "23. Pseudo selectors" it said:

Remember: your paragraph is the third paragraph, but the fourth CHILD of body. The h3 counts as the first child!

The HTML looks like this:

<body>

	<h3 class="fancy">
	    some h3
	</h3>

	    <p class="fancy">
	    some paragraph 
	    </p>

	 <p id="serious">
	 some other par
	 </p>

	 <p>
	 third par
	 </p>

</body>

and my stylesheet looks like this:

.fancy {
font-family: Cursive;
color: violet;
}

#serious {
font-family: Courier;
color: #8C8C8C;
}

p:nth-child(4) {
font-size: 26px;
}

How can I know that the BODY tag is the parent and the h3, p, p, p are its children?

The mistake I did was I had the child set to nth-child(3) instead of nth-child(4)

Would really appreciate an explanation of how to identify which element is the parent.


#4

take a look at the code in this lesson. all elements are children of body here, so p:nth-child(4) will target the 4th element is the 4th element is a paragraph, a better way to explain this would say p:first-child won't "execute"/apply the styling between the curly brackets since the first child is h3, not a paragraph