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 trial
Amanda Zimmer
930 PointsCode Challenge: Using Combinators in Selectors
Has anyone done the code challenge for "Using Combinators in Selectors? I've been trying to wrap my head around it now for about 45 minutes and I can't seem to get the right answer... Create a child selector to target the anchor element that is a direct child of the div. Set its color to green and font weight to bold.
> Child Selctor
a Anchor
div > a {
color: green;
font-weight: bold;
}
what am I doing wrong?
13 Answers
Chase Lee
29,275 PointsDon't use the greater than sign.
Adrian Mardari
1,116 Points div > a {
color: green;
font-weight: bold;
}
```
Jaap Steenis
Courses Plus Student 1,977 PointsProper solution is as follows:
Add a class="main" to the div tag (not a class id, that doesn't work)
Followed by the css style
.main > a { color: green; font-weight:bold; }
That gave me Green :-) and not a bummer
Abdillah Hasny
10,633 PointsError Case sam with me :o
Becky Pate
1,667 Pointssame here!
David Rabie
5,254 Pointshahah Same here!
David Rabie
5,254 Pointshahah Same here!
Tate Hanawalt
16,895 PointsWhy don't you use the greater then? That is the character they used in the video and I am using it in practice code but for a div with a specific id.
Arin Carmack
1,281 PointsThe initial answer did not work for me. I added the the class="main" to the div tag and then passed by placing in- a { color: green; font-weight: bold; }
That worked.
Jodie Wong
3,522 PointsGo to the div tag and give it a class=main. Like this:
<body>
<h1>Combinators</h1>
<div class="main">
Then go back to your CSS, so instead of .div > a etc. You have .main.
So you have this:
.main > a {
color: green;
font-weight: bold;
}
Not this:
.div> a {
color: green;
font-weight: bold;
}
Matt Ensor
3,278 PointsThanks :)
Matt Ensor
3,278 PointsThanks :)
nl9
1,478 PointsI don't understand why you should not use the >... The question asked to only include ones that directly follow, which is represented by the "greater than" sign. Can someone explain that to me?
Amanda Zimmer
930 PointsAmanda Zimmer
930 PointsI'm such an idiot...
I really can't believe I did that :( Thanks so much for responding.
Chase Lee
29,275 PointsChase Lee
29,275 PointsYour welcome.