16.7 Extend (“@extend”)
In addition to mixins, there’s another way to avoid unnecessary repetitions, namely extends. It often happens with many selectors that they differ only by a few properties. The extends can be used in two different ways. First, I’ll show you how to use @extend to split the CSS features of a selector and override or extend the necessary features in the new selector. In the example, we create the .my-article class selector as the base class for the other two class selectors, .my-article-top and .my-article-std, where we only change or override the color of the base class. Of course, you could also expand the two new classes. The extension is made here via @extends selector name. Any type of selector such as class selector, ...
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.
Read now
Unlock full access