Can you swing it?


#1

Hi,
I'm doing this exercice : https://www.codecademy.com/courses/web-beginner-en-WF0CF/1/4?curriculum_id=50579fb998b470000202dc8b#
But, I can't find solution.


/*Add your CSS below!*/

p {
    font-family: Garamond;
}

div > p {
    color: #7AC5CD;   
}

ul li {
    color: #000000;
    text-decoration: none;
}

HTML is exactly the same.


#2

you still need to target the introduction and summary paragraph, which are a direct child of body. Also, ul li should be ul li p, i don't agree with this, but the instructions explicitly state that paragraph should be part of the css selector


#3

Here's how I did it, but I didn't quite understand what they meant by > (Do NOT use the universal selector for this! There's a better way; see the Hint for help.).
p {
font-family: Garamond;
}
body > p {
font-weight: bold;
}
div > p {
color: #7AC5CD;
}
li > p {
color: #000000;
text-decoration: underline;
}


#4

> will only affect direct children:

<body>
  <p>i am affected</p>
  <div>
    <p>i am not</p>
  </div>
</body>

p or body p will affect all paragraphs nested somewhere inside body. Where as body > p will only affect paragraphs which have body as direct parent. In the above code, that is only the first paragraph, the second paragraph has div as direct parent.


#5

Thank you. But I do actually understand CSS selectors. I was referring to what they said in the lesson about the universal selector, and tried to quote a text from the actual lesson, but this discussion software isn't being conventional when it comes to formatting. I had the text I was trying to quote pasted and selected then I clicked the 'Blockquote' icon in the toolbar.. This added the >in front of the selected text instead of formatting it as a quoted piece. Here's what I was referring to when I wrote "but I didn't quite understand what they meant by.." (this time quoted using the quote tags):

Why would we use the universal selector, which uses an asterix and affects all Ps, when we could simply use

?


#6

no, the catch is that if people read all they might think they need the universal selector (*) while you should NOT use it. The universal selector would more then just the paragraphs, which is why p is the better solution


#7

Why would I need the > if "div p" or "body p" have worked for me previously? Also does < make a difference?


#8

> will only affect direct children, that is a huge difference. That is why you need it. < isn't anything


#9

But I don't get why when you do:
body>p{
font-weight: bold;
}

it doesn't bold everything. Or just the introduction.


#10

omg dude thanks so much that helped a lot as well explain what was going on lol.


#11

body > p will only affect the direct children inside body, the introduction and summary paragraph. The synopsis paragraph isn't a direct child of body, it is inside a div


#12

Shame on Codeacademy for putting out such a terribly written question.


#13

The catch is that you are confusing people by providing redundant information in the question.


#14