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

William Yeung
William Yeung
11,331 Points

Extended Element

Does the class being extended need to be present in the HTML? Or can you just create it in the SCSS file? Because here, I don't see .btn in the HTML anywhere.

1 Answer

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

When you create an extend with a class name, and you include the extend directive with other css rules, you will be outputting that class name from the extend with those rules. It is better to create a placeholder instead so that you don't have to make these classes in your markup.

A good example of a placeholder extend is a clearfix. A placeholder is declared by using the % sign followed by the name:

%clearfix {
  content: '';
  display: table:
  clear: both;
}

.selector {
  @extend %clearfix;
}

.selector-2 {
  @extend %clearfix;
}

Using this method has the advantage of not needing to make a class for the clearfix.