Sass | @at-root rule Last Updated : 15 Jul, 2025 Comments Improve Suggest changes Like Article Like Report The @at-root rule emits everything inside the rule at the root of the file rather than using normal nesting. It's mostly used during advanced nesting with the SassScript parent selector and selector functions. Syntax: css @at-root <selector> { ... } Example: css @use "sass:selector" @mixin geeks($gfg) @at-root #{selector.unify(&, $gfg)} @content .block .font @include geeks("input") times new roman @include geeks("select") arial This would result in the following output: .block input.font { times new roman; } .block select.font { arial; } The @at-root rule is required in the above example as Sass doesn’t know about the interpolation that was used for generating the selector while performing the selector nesting. It automatically adds the outer selector to the inner selector even if & it is used as a Sass expression. Sass is explicitly told not to include the outer selector by the @at-rule. Style Rules: The @at-root rule gets rid of the style rules. Only the at-rules like @media are included by default. But if required, it can be controlled as what and what not is included in the results. Example: css @media geeks .gfg color: green @at-root (without: media) font-family: times new roman @at-root (with: rule) font-size: 4px This would result in the following output: @media geeks { .gfg { color: green } } .gfg { font-family: times new roman } .gfg { font-size: 4px; } Along with the names, some other special values can also be used in the queries: rule means the style rules, this excludes all at-rules but preserves the style rules. all means all the at-rules and style rules must be excluded. Comment More infoAdvertise with us Next Article Sass | At-rules S Slash_IT Follow Improve Article Tags : CSS SASS Similar Reads Sass | At-rules At-rules are simply some CSS statements that instructs the CSS how to behave in particular conditions. They start with an "@" sign, followed by an identifier and ends with a semicolon (in case of SCSS), or the next CSS statement (in case of SASS), depending upon the Sass syntax used. Syntax: css @i 2 min read SASS @for Rule The @for rule in SASS is used to count up or down from one number to another and check the section for every number that comes in between the given range. Every number is assigned a variable name that can be accessed in the loop. It can be used in two ways: 1. start through end: In this type, the "s 2 min read SASS | @forward rule The @forward rule processes the Sass stylesheets and makes their functions, mixins, and variables available in the cases when the stylesheet is loaded using @use rule. Organizing Sass libraries across many files are made possible, along with providing users to process a single entry point file. Synt 3 min read Sass @each Rule The @each rule is used to emit styles or evaluate codes for each element of a list or each pair of a map. It is most advantageous for repeating styles that have a few differences in them. The section is evaluated for every element of the list or pair of the map which has been assigned to the provide 2 min read Sass @function Rule Functions can define complex operations on SassScript values that can be reused throughout the stylesheet. It makes it easier to abstract out the common formulas and behaviors in some readable way. Functions can be defined using @function at-rule. Syntax: html @function <function name>(<arg 2 min read Sass @extend Rule The sass @extend rule can be used when it is necessary for a class to have the styles of another class, along with its own specific styles. This rule tells Sass that one selector should inherit the class from another selector.Syntax:@extend <selector>Example: This example shows the use of the 3 min read Like