Psuedo selectors


#1

I've tried every type of scenario:

<!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">i am a header</h3>
    <p class="fancy">First paragraph. </p>
    <p id="serious">Second paragraph.</p>
    <p>Third paragraph.</p>
	
	</body>
</html>

/*Add your CSS below!*/
#serious {
    font-family: Courier; color:#8C8C8C
}
.fancy {
    font-family:cursive; color:violet
}
body: nth-child(4) {
    font-size:26px
}

#2

I can't see your HTML
How to insert code into a post


#4

when selecting the 4th child in body, make sure you get the spacing in body :nth-child(4) right, it isn't in your case.

@zainabrawat, i thought cursive was a font-family which started with a lowercase c? Too lazy too check :stuck_out_tongue:


#5

@stetim94 I had my doubts about it being uppercase or lowercase, I suggested it to another learner and it worked thus I mentioned it..


#6

I'm having the very same problem. I'm doing everything right. It's telling me I haven't set my font-size to 26px.
My coding is like so - body :nth-child(4) { font-size:26px }
I've tried all the opening and closing spaces - still won't go through.


#7

Can i see your full html and css code? This only works if this the rest of the code is also correct


#8

Hi Stetim,
Here is the coding.

<!DOCTYPE html>
<html>
	<head>
		<link type="text/css" rel="stylesheet" href="stylesheet.css"/>
		<title>Result</title>
	</head>
	<body>
		<h3 class="fancy">This Okay?<h3>
		   <p class="fancy">This is a paragraph</p>
		   <p id="serious">This is another paragraph</p>
		   <p>This is a third paragraph</p>
		
	</body>
</html>

Sorry - I'll cut and paste the CSS now.


#9

your h3 closing tag is missing a slash, which screws up the count of nth-child

for next time, use one of the two following options to make your code/indent is visible:

select your code and press ctrl + shift + c (or cmd + shift + c if you use a mac)

if this instructions are unclear, you can also insert 3 backticks before and after your code, like so:

```
<p>visible</p>
```

the backtick is located above the tab key on your keyboard


#10

Hurrah!! You're a total star stetim94!
That's done the trick. Well spotted. Thanks!!


#11

hello, everyone, for the nth-child selector, why do we have to put space between body and :nth-child?
for the p:nth-child(n), we are not asked to do so??

thank you


#12

to select the 4th element inside body.

this will select the 4th element (if it is a paragraph) of any parent