This forum is now read-only. Please use our new forums! Go to forums
23/23, Same problem as others -- my fourth paragraph won't recognize 26px
HTML and CSS pasted below, any thoughts? I did reset my zoom, I don’t think that’s the issue, and also tried body: nthchild(4) with the space rather than p:nthchild(4) as it reads below
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
<title>Result</title>
</head>
<body>
<!--Add your HTML below!-->
<h3 class="fancy">Header</h3>
<p class="fancy">paragraph</p>
<p id="serious">second paragraph I guess</p>
<p>third paragraph</p>
</body>
</html>
.fancy { font-family: cursive;
color: violet;
}
#serious {
font-family: Courier;
color: #8C8C8C;
}
p:nthchild(4) {
font-size: 26px;
}
Answer 55f1409d95e37831a90002ce
Answer 55faa96895e37837e200008e
Heey Amar,
if you want to use body, use body :nth-child(4)
(with space between body and the colon) this tells css it looks for 4th child in body.
Yea, but nth-child counts all elements and if the 4th element is a paragraph, apply the css. Here is a example which might help:
<h1>i am header</h1><!-- h1:nth-child(1) or h1:first-child -->
<p>i am a paragraph</p><!-- p:nth-child(2) -->
<h2>i am a header</h2><!-- h2:nth-child(3) -->
<p>i am a paragraph</p><!-- p:nth-child(4) or p:last-child -->
As you can see more clearly from this example, all elements are included in the count, if you would apply p:first-child on this html code, nothing would happen. the first element is a h1, not a paragraph. So the css code doesn’t get applied/“executed”
Same with the html code from the exercise, you understand now?
Popular free courses
- Free Course
Learn SQL
In this SQL course, you'll learn how to manage large datasets and analyze real data using the standard data management language.Beginner friendly,4 LessonsLanguage Fluency - Free Course
Learn JavaScript
Learn how to use JavaScript — a powerful and flexible programming language for adding website interactivity.Beginner friendly,11 LessonsLanguage Fluency - Free Course
Learn HTML
Start at the beginning by learning HTML basics — an important foundation for building and editing web pages.Beginner friendly,6 LessonsLanguage Fluency
3 comments
Thanks for the help! Yes, I read enough of the answers to get the formatting right but obviously not enough to spot my missing hyphen! Thanks again
you’re welcome
Hello! I hava a doubt here . In the above code,i noticed that p:nth-child(4) was used.However, there are only 3 paragraphs present in the HTML code.Should not it be body:nth-child(4).Am I missing out something. Thanks, Aman