Sass supports every plain CSS at-rule. Most of them are written exactly as in CSS and compiled straight through. A few—@media and @supports—also understand Sass features such as nesting, SassScript (variables, maps, math), and interpolation with #{}.
Any at-rule Sass does not recognise is treated as an unknown at-rule and is emitted as written, with interpolation allowed in its parameters.
Nesting swap.
When you nest @media or @supports inside a style rule, Sass bubbles the at-rule to the top and moves the style rule inside it. You write selector-first; the CSS comes out at-rule-first.
Merged queries.
Nested @media rules combine into one query with and (for example (min-width: 640px) and (orientation: landscape)).
Not the same as Sass at-rules.
Rules like @use, @mixin, @if, and @each are Sass features and never reach the CSS. This page covers the CSS at-rules Sass passes through. See the at-rules hub for the Sass ones.
Syntax
Syntax
SCSS
$tablet: 768px;
$query: "screen and (max-width: 600px)";
.card {
padding: 1rem;
// Nested @media bubbles to the root
@media (min-width: $tablet) {
padding: 2rem;
}
// Whole query via interpolation
@media #{$query} {
padding: 0.5rem;
}
// Nested @supports bubbles the same way
@supports (display: grid) {
display: grid;
}
}
@keyframes fade {
from { opacity: 0; }
to { opacity: 1; }
}
Pattern: write the at-rule where it belongs next to its selector → let Sass bubble and merge → use $variables, map.get(), and #{} inside queries when values need to be reused.
Reference
At-Rule Behavior at a Glance
How Sass treats the common CSS at-rules:
At-rule
Inside a style rule
SassScript / interpolation
@media
Bubbles to the root; nested queries merge with and
Variables, maps, and math in feature values; #{} for whole queries
@supports
Bubbles to the root like @media
Values and #{} in the condition
@keyframes
Emitted at the stylesheet root
#{} in the animation name; variables inside frames
@font-face
Write at the top level
Variables in declaration values
@container / @layer
Bubble like @media (selector wrapped inside)
#{} in the parameters
Other unknown at-rules
Passed through as written
#{} in the parameters
Selectors vs queries.
Interpolation is the right tool for whole queries or names. For a single value inside parentheses, plain SassScript like (min-width: $tablet) is enough.
All CSS at-rules work in Sass; unknown ones pass through.
@media and @supports bubble out of style rules and merge when nested.
SassScript and #{} let variables and maps drive queries.
Sass at-rules (@use, @mixin, …) never appear in the CSS.
One line: write CSS at-rules next to your selectors and let Sass bubble, merge, and interpolate them.
Practice
Compile Notes
Practical checklist:
checklist.txt
1. Nest @media / @supports beside the rule they affect
2. Store breakpoints in variables or a map
3. Use #{$query} when a whole query lives in a variable
4. Expect nested queries to merge with "and"
5. Check the compiled order if cascade matters
Frequently Asked Questions
Yes. Plain CSS at-rules such as @media, @supports, @keyframes, @font-face, @container, and @layer are all written as normal. Sass emits unknown at-rules as written.
Sass bubbles the @media rule to the top level and places the style rule inside it, so you can write breakpoints next to the selectors they change.
Yes. Sass merges them into a single query joined with and, for example (min-width: 640px) and (orientation: landscape).
Yes. Variables, map lookups, and math work inside feature values like (min-width: $tablet). Use #{} to interpolate a whole query string.
Yes. Values in a @supports declaration are SassScript, and you can interpolate property names or the condition with #{}.
CSS at-rules are emitted into the compiled stylesheet. Sass at-rules such as @use, @mixin, @if, and @each run at compile time and never appear in the CSS.