The Sass @extend rule is written @extend <selector>;. It tells Sass that one selector should inherit the styles of another.
Unlike mixins, which copy styles into the current rule, @extend updates style rules that contain the extended selector so they also include the extending selector. Write class="error--serious" in HTML and Sass styles it as though it also had class="error". Prefer mixins when you need arguments or non-semantic style chunks.
Official pattern.
Per the Sass docs: use @extend for semantic relationships (a modifier is a block). Sass merges selectors and extends everywhere the target is used, including :hover.
Resolved late.
Extends run after the rest of the stylesheet — including parent-selector nesting. @extend .error does not rewrite nested &__icon rules.
Only simple selectors.
Do not extend compounds like .message.info or descendants like .main .info. Write @extend .message, .info instead.
Most @extend bugs are wrong targets, media boundaries, or choosing extend when a mixin fits better.
simple
Only simple selectors
@extend .message.info and @extend .main .info are disallowed. Extend each simple selector separately.
media
Stay inside the same @media
You may extend inside @media, but not across a selector defined outside that at-rule.
cascade
Order follows the extended rule
Cascade precedence comes from where the extended styles appear, not where you wrote @extend.
mixin
Need arguments? Use a mixin
Official tip: extends shine for semantic class relationships. Configurable chunks belong in @mixin.
Toolchain
Sass Support
@extend is a core Dart Sass at-rule. Prefer Dart Sass for modern rules (simple-selector-only extends, @use scope).
Implementation
Status
Dart Sass
Supported (recommended)
LibSass / node-sass
Supported (deprecated; compound extends legacy)
Ruby Sass
Supported (end-of-life)
Browsers
N/A — only see merged CSS selectors
Prefer Dart Sass for new projects. SCSS and indented syntax both support @extend.
Remember
Key Takeaways
Merge:@extend shares styles by rewriting selector lists.
Placeholders (%) are silent bases meant only to be extended.
Semantic relationships fit extend; configurable chunks fit mixins.
Simple selectors only; use !optional when a miss is OK.
One line:@extend says “this selector is also that one” and rewrites the CSS accordingly.
Compile
Compile Notes
@extend never reaches the browser. Conceptual flow:
flow.txt
1. Compile nesting and the rest of the stylesheet
2. Collect @extend relationships
3. Unify selectors (skip impossibles, interleave safely)
4. Rewrite rules that contain the extended selector
5. Emit CSS — placeholders without extenders are dropped
Frequently Asked Questions
It tells Sass that one selector should inherit the styles of another. Sass updates style rules that contain the extended selector so they also include the extending selector.
Mixins copy styles into the current rule. @extend merges selectors so shared styles appear once with a selector list. Use extends for semantic relationships; use mixins for configurable style chunks.
A selector that starts with % (like %message-shared). Rules that only use placeholders are omitted from CSS until something @extends them.
Normally @extend errors if the target selector is missing. Add !optional to silently do nothing when the extended selector does not exist.
No in modern Dart Sass. Only simple selectors can be extended. Write @extend .message, .info instead of @extend .message.info.
Yes, but you can only extend selectors defined inside the same at-rule. Extending a selector that appears outside the @media is an error.