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

Gordon Parmenter
Gordon Parmenter
10,344 Points

stuck on last challenge

Task 4 of 4 - Following code submitted but keeps failing. Not clear what I am doing wrong with attempts to add an exception for <a> in div with class footer to have links purple. Is there a way to circumvent this task?

/* Write your SCSS code below. */ p { a { color: red;

.footer & { 
    color: purple;
}

}

a { color: blue;

&:hover{
  opacity: 0.5;
}  

}

}

4 Answers

David Valles
David Valles
18,487 Points

Gordon,

Try:

p {
  a {
    color: red;
  }
  > a {
    color: blue;

    &:hover {
      opacity: 0.5;
    }
    div.footer & {
      color: purple;
    }
  }
}

I'm not sure if it's an error in the challenge but it will pass when nested in the p a rule as long as you're specific enough with the selector..

I don't think the instructions are clear enough on which one it should be in.

Hi Gordon,

The challenge wants you to be more specific. It's a div with a class of "footer" not just any element with a class of "footer"

Gordon Parmenter
Gordon Parmenter
10,344 Points

Thank-you both for your answers. David's solution worked fine.

I had tried this variation earlier, just within the first a rule not the second and had put a space between the tag dive and class footer.

You are right Jason, the solutions have to be just so for them to be acceptable. Still enjoying the courses.

Hi Gordon,

What I meant was your solution would pass with div.footer Both the code that you have and the code that David posted will pass the challenge. It doesn't seem to matter which rule you nest it in.

Gordon Parmenter
Gordon Parmenter
10,344 Points

Thanks Jason Good to know I wasn't going crazy. Tried every combination should have realised the space wasn't required. Working through web design course and CSS section of course seems a long time ago.