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

Opacity wont set from Sass

Challenge task 3 of 4 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.

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

Keeps returning to set the opacity to 0.5

3 Answers

Tom Bedford
Tom Bedford
15,645 Points

You have closed the >a curly bracket before adding &:hover. When it compiles it's making p:hover not p > a:hover. There also doesn't appear to be a final closing bracket for p.

Your current code with (with the added final closing bracket) would compile to:

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

wow i just saw this. thanks alot

so this is correct?

/* Write your SCSS code below. */
p{
a{color:red;}
>a{color:blue; &:hover{opacity:0.5;}}
}