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

STAGE 2 CHALLENGE TASK 1 OF 3

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:#369;
.dogs {
extend .animals;
}}

1 Answer

Ken Alger
STAFF
Ken Alger
Treehouse Teacher

Let's look at the general syntax of the @extend directive in Sass.

.foo {
  color: blue;
  border: 1px solid black;
}

.bar {
 @extend .foo
}

This will extend the CSS properties in the foo class to the bar class.

Post back if you are still stuck on the challenge.

Ken