Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

CSS Sass Basics (retired) Getting Started with Sass Advanced Nesting

Richard Barkinskiy
Richard Barkinskiy
10,663 Points

Adding an exception...

Here's my code:

/* Write your SCSS code below. */ p {

a { color:red; .footer div & { color: purple; } }

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

How do I add the .footer div exception to the anchor links inside so that they're purple?

index.html
<!DOCTYPE html>
<html>
<head>
  <title>Sass Basics - Code Challenge</title>
  <link rel="stylesheet" type="text/css" href="page-style.css">
  <link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
  <h1>Hampton's Blog</h1>
  <div class="entry">
    <h1><a href="#">Delicious Food in SF</a></h1>
    <div class="content">
      <p>
        You know what my favorite restaurant in San Francisco is? The answer is that there are so many great restaurants that I couldn't choose one. But honorable mentions include <a href="#">Mr. Chow's</a>, <a href="#">Live Sushi</a> and <a href="#">Piccino</a>. 
        <span class="link"><a href="/info.html">Read More</a></span>
      </p>
    </div>
  </div>
  <div class="entry">
    <h1><a href="#">Great Music</a></h1>
    <div class="content">
      <p>
        Here are some of my favorite bands from years past and present: Belle and Sebastian, Pixies, and Daft Punk. Listening to music allows me to focus when I'm programming. 
        <span class="link"><a href="/info.html">Read More</a></span>
      </p>
    </div>
  </div>
  <div class="footer">
    <p>
      Thanks for reading my blog!  Be sure to check out my <a href="#">other articles</a>.
    </p>
  </div>
</body>
</html>
style.scss
/* Write your SCSS code below. */
p {

  a {
    color:red;
    .footer div & {
      color: purple;
    }
  }
  > a{
    color:blue;
    &:hover {
      opacity:0.5;
    }
  }
}

2 Answers

Richard Barkinskiy
Richard Barkinskiy
10,663 Points

Finally figured it out. Here's the final Sass code:

p {
  a{
    color:red;
    div.footer &{
      color:purple;
    }
  }
  > a {
    color:blue;
    &:hover{
      opacity:0.5;
    }
  }
}

The questions for this challenge were confusing to say the least. Plus even though div.footer == .footer it still kept saying the code was incorrect, even though it's not.

At the end of your CSS file put:

a.footer {
color: purple;
}

You're putting it after the original anchor styling so that it overwrites. Hierarchy stuff.