Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialKent Drummond
8,309 Pointsneed help with selectors
div > p { color: green; font-weight: bold; }
error: child selector uses >, make sure to set color to green.
can anyone point me in the right direction Thanks
4 Answers
Dustin Scott
Courses Plus Student 7,819 PointsThis is the answer :
div a{
color :green;
font-weight:bold;
}
div p{
background: lightblue;
}
Try it and tell me the result
Jason Anello
Courses Plus Student 94,610 PointsHi Kent,
The challenge wants you to target the anchor element that is a direct child of the div whereas you've targeted the paragraph that is a direct child of the div. Everything else looks good. You're using the correct combinator >
This particular error message is misleading.
Kent Drummond
8,309 Pointsthanks for the help
Guil Hernandez
Treehouse TeacherThanks, Jason Anello . I'll take a look at why this is happening. :)
Jason Anello
Courses Plus Student 94,610 PointsThanks, Guil
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsThis does pass so I believe this challenge has an error in it. It's asking to target direct children so you should be using
>
The descendant selector you have above,
div a
, should not be passing the challenge.Dustin Scott
Courses Plus Student 7,819 PointsDustin Scott
Courses Plus Student 7,819 PointsI did that and it's working even in my text editor
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsHi Dustin,
Whether you notice a difference between
div a
anddiv > a
is going to depend on the html.If you look at the html in the challenge you will see that there are two links which are direct children of the div but there's also a link in the last paragraph. This link is not a direct child of the div. So there are 3 links total in that div.
If you do this:
That's going to target all descendant links of the div. So all 3 links will be green.
If you do this:
Only the 2 direct child links of the div will be green. The link in the paragraph will not be affected by this.
So depending on what html you have you may or may not notice a difference between these two but there is an important difference between the two selectors.
Dustin Scott
Courses Plus Student 7,819 PointsDustin Scott
Courses Plus Student 7,819 PointsYeah 100% you are right but when you do this in the challenge it will not accept. In the first time I got into this challenge I did div > p it says wrong then I tried div p then it works it's a bug I think
Jason Anello
Courses Plus Student 94,610 PointsJason Anello
Courses Plus Student 94,610 PointsAre you talking about task 2 now? I thought the original question was about task 1.
I just checked task 2 and it passed with both
div p
anddiv > p
but neither of these selectors should pass.You're supposed to use the adjacent sibling selector
h2 + p
This will target paragraphs that immediately follow anh2
Guil Hernandez This challenge seems to be passing with incorrect answers.