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) Variables, Mixins, and Extending Selectors Extending Selectors

JESSE VALLBADASS
PLUS
JESSE VALLBADASS
Courses Plus Student 6,017 Points

Style the class .animals to have a background of #369. Use "extend" to apply those styles to a new class, .dogs.

Style the class .animals to have a background of #369. Use "extend" to apply those styles to a new class, .dogs.

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>
  <div class="animals">
    Animals
  </div>
  <div class="dogs">
    Dogs
  </div>
  <div class="message_box">
    My favorite animals are: <a href="http://en.wikipedia.org/wiki/Dog" target="_blank">Dogs!</a>
  </div>
</body>
</html>
style.scss
/* Write your SCSS code below. */
% animals {
    background-color: #369;
}

.dogs { 
    @extend %animals;
}

2 Answers

stjarnan
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
stjarnan
Front End Web Development Techdegree Graduate 56,488 Points

They want you to style a class, and then extend that class when styling the dogs class. Here's how it might look:

.animals {
  background-color: #369;
}

.dogs {
  @extend .animals;
}
Eric Mckee
Eric Mckee
16,081 Points

It's weird, but it looks like they want you to make a placeholder and then use that to extend.

%animals { background-color: #369; }

.animals { @extend %animals; } .dogs { @extend %animals; }