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 Sass Basics (retired) Getting Started with Sass Advanced Nesting

We want to add a style to our previous Sass code declaring that on hover, all direct <a> children have an opacity of 0.5. Use the ampersand selector to achieve this, rather than repeating the > a direct child selector.

the following code I have written is not working. can somebody help?

p > a {
  color: blue;
  &:hover {
     opacity: 0.5;
}
}
Jay McGavren
Jay McGavren
Treehouse Teacher

Reena,

Steps 1 and 2 in that code challenge were allowing rules that weren't nested; they should have been required to be nested. Step 3 did enforce that requirement, which could understandably lead to confusion. We've fixed the challenge to check for nesting, and to provide helpful hints if the rules aren't nested.

If you have any further issues, please let us know at help@teamtreehouse.com . Sorry for the trouble!

Thank you.

Surendra Kulkarni
Surendra Kulkarni
6,826 Points

If treehouse could check the wording of the question so that they convey the intended meaning, will help considerably to save time and frustration.

6 Answers

Hi Reena,

The Sass you put in is technically correct and would work. Unfortunately, it's not exactly what the Code Challenge is looking for since it's about nesting more advanced selectors. It actually wants you to nest every rule. Here's the format it's looking for:

p {
   a {
     color: red;
   }
   > a {
     color: blue;
     &:hover {
       opacity: 0.5;
     }
   }
 }

We'll fix this so it's a little more forgiving and gives you better hints.

something is wrong...I pretty had the same answer as you have here, but it keeps telling me "Bummer...."

what is actually not working?

best answer

try this guys p{

a{ color:red;

}

a{ color: blue; &:hover { opacity: 0.5; }

}

}

James Barnett
James Barnett
39,199 Points

Well for one thing the first step of that code challenge is ...

Use a nested selector to say all <a> tags within <p> tags are red.