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

CSS

Code 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

Don't use the greater than sign.

I'm such an idiot...

    div < a {
            color: green;
            font-weight: bold;
   }

I really can't believe I did that :( Thanks so much for responding.

Your welcome.

            div > a {
            color: green;
            font-weight: bold;

}
            ```

Proper 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

Error Case sam with me :o

same here!

hahah Same here!

hahah Same here!

Why 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.

The 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.

Go 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;
}

Thanks :)

Thanks :)

I 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?