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

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.