Skip to Content
Pragmatic Guide to Sass 3
book

Pragmatic Guide to Sass 3

by Hampton Lintorn Catlin, Michael Lintorn Catlin
July 2016
Intermediate to advanced
130 pages
2h 11m
English
Pragmatic Bookshelf
Content preview from Pragmatic Guide to Sass 3
32Using Placeholders with @extend

In the previous task, you learned about @extend. It was used to extend a .button class. Those styles were applied to two new classes, which could then be used in some markup. But you don’t really need the .button selector as it’s too generic. It’s only being used to extend its style rules onto other selectors.

This is where placeholders come in. You can define a placeholder by using the % sign. Then, you declare your styles as usual, and you can extend the styles to other classes as seen in the example.

On compilation, though, placeholders are omitted from the final output. In the example, this means that the %button placeholder selector is not present in the output. This keeps your final CSS cleaner.

At ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Jump Start Sass

Jump Start Sass

Hugo Giraudel, Miriam Suzanne
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
Mastering Sass

Mastering Sass

Luke Watts

Publisher Resources

ISBN: 9781680502060Errata Page