🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 112 (from laksa125)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

đź“„
INDEXABLE
âś…
CRAWLED
19 minutes ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://sass-lang.com/guide/
Last Crawled2026-04-11 21:55:28 (19 minutes ago)
First Indexed2019-04-02 15:38:46 (7 years ago)
HTTP Status Code200
Meta TitleSass: Sass Basics
Meta DescriptionSyntactically Awesome Style Sheets
Meta Canonicalnull
Boilerpipe Text
Before you can use Sass, you need to set it up on your project. If you want to just browse here, go ahead, but we recommend you go install Sass first. Go here if you want to learn how to get everything set   up. Preprocessing Preprocessing permalink CSS on its own can be fun, but stylesheets are getting larger, more complex, and harder to maintain. This is where a preprocessor can help. Sass has features that don’t exist in CSS yet like nesting, mixins, inheritance, and other nifty goodies that help you write robust, maintainable   CSS . Once you start tinkering with Sass, it will take your preprocessed Sass file and save it as a normal CSS file that you can use in your   website. The most direct way to make this happen is in your terminal. Once Sass is installed, you can compile your Sass to CSS using the sass command. You’ll need to tell Sass which file to build from, and where to output CSS to. For example, running sass input.scss output.css from your terminal would take a single Sass file, input.scss , and compile that file to output.css . You can also watch individual files or directories with the --watch flag. The watch flag tells Sass to watch your source files for changes, and re-compile CSS each time you save your Sass. If you wanted to watch (instead of manually build) your input.scss file, you’d just add the watch flag to your command, like   so: sass --watch input.scss output.css You can watch and output to directories by using folder paths as your input and output, and separating them with a colon. In this   example: sass --watch app/sass:public/stylesheets Sass would watch all files in the app/sass folder for changes, and compile CSS to the public/stylesheets folder. 💡 Fun fact: Sass has two syntaxes! The SCSS syntax ( .scss ) is used most commonly. It’s a superset of CSS , which means all valid CSS is also valid SCSS . The indented syntax ( .sass ) is more unusual: it uses indentation rather than curly braces to nest statements, and newlines instead of semicolons to separate them. All our examples are available in both   syntaxes. Variables Variables permalink Think of variables as a way to store information that you want to reuse throughout your stylesheet. You can store things like colors, font stacks, or any CSS value you think you’ll want to reuse. Sass uses the $ symbol to make something a variable. Here’s an   example: SCSS Sass CSS Playground SCSS Syntax $font-stack : Helvetica , sans-serif ; $primary-color : #333 ; body { font : 100% $font-stack ; color : $primary-color ; } Playground Sass Syntax $font-stack : Helvetica, sans-serif $primary-color : #333 body font : 100 % $font-stack color : $primary-color CSS Output body { font : 100% Helvetica , sans-serif ; color : #333 ; } When the Sass is processed, it takes the variables we define for the $font-stack and $primary-color and outputs normal CSS with our variable values placed in the CSS . This can be extremely powerful when working with brand colors and keeping them consistent throughout the   site. Nesting Nesting permalink When writing HTML you’ve probably noticed that it has a clear nested and visual hierarchy. CSS , on the other hand,   doesn’t. Sass will let you nest your CSS selectors in a way that follows the same visual hierarchy of your HTML . Be aware that overly nested rules will result in over-qualified CSS that could prove hard to maintain and is generally considered bad   practice. With that in mind, here’s an example of some typical styles for a site’s   navigation: SCSS Sass CSS Playground SCSS Syntax nav { ul { margin : 0 ; padding : 0 ; list-style : none ; } li { display : inline-block ; } a { display : block ; padding : 6px 12px ; text-decoration : none ; } } Playground Sass Syntax nav ul margin : 0 padding : 0 list-style : none li display : inline-block a display : block padding : 6px 12px text-decoration : none CSS Output nav ul { margin : 0 ; padding : 0 ; list-style : none ; } nav li { display : inline-block ; } nav a { display : block ; padding : 6px 12px ; text-decoration : none ; } You’ll notice that the ul , li , and a selectors are nested inside the nav selector. This is a great way to organize your CSS and make it more   readable. Partials Partials permalink You can create partial Sass files that contain little snippets of CSS that you can include in other Sass files. This is a great way to modularize your CSS and help keep things easier to maintain. A partial is a Sass file named with a leading underscore. You might name it something like _partial.scss . The underscore lets Sass know that the file is only a partial file and that it should not be generated into a CSS file. Sass partials are used with the @use rule. Modules Modules permalink Compatibility: Dart Sass since 1.23.0 LibSass ✗ Ruby Sass ✗ Only Dart Sass currently supports @use . Users of other implementations must use the @import rule instead. You don’t have to write all your Sass in a single file. You can split it up however you want with the @use rule. This rule loads another Sass file as a module , which means you can refer to its variables, mixins , and functions in your Sass file with a namespace based on the filename. Using a file will also include the CSS it generates in your compiled   output! SCSS Sass CSS SCSS Syntax // _base.scss $font-stack : Helvetica , sans-serif ; $primary-color : #333 ; body { font : 100% $font-stack ; color : $primary-color ; } // styles.scss @use 'base' ; .inverse { background-color : base. $primary-color ; color : white ; } Sass Syntax // _base.sass $font-stack : Helvetica, sans-serif $primary-color : #333 body font : 100 % $font-stack color : $primary-color // styles.sass @use 'base' .inverse background-color : base. $primary-color color : white CSS Output body { font : 100% Helvetica , sans-serif ; color : #333 ; } .inverse { background-color : #333 ; color : white ; } Notice we’re using @use 'base'; in the styles.scss file. When you use a file you don’t need to include the file extension. Sass is smart and will figure it out for   you. Mixins Mixins permalink Some things in CSS are a bit tedious to write, especially with CSS3 and the many vendor prefixes that exist. A mixin lets you make groups of CSS declarations that you want to reuse throughout your site. It helps keep your Sass very DRY . You can even pass in values to make your mixin more flexible. Here’s an example for theme . SCSS Sass CSS Playground SCSS Syntax @mixin theme ( $theme : DarkGray ) { background : $theme ; box-shadow : 0 0 1px rgba ( $theme , .25 ) ; color : #fff ; } .info { @include theme ; } .alert { @include theme ( $theme : DarkRed ) ; } .success { @include theme ( $theme : DarkGreen ) ; } Playground Sass Syntax @mixin theme($theme: DarkGray) background : $theme box-shadow : 0 0 1px rgba( $theme , .25) color : #fff .info @include theme .alert @include theme($theme: DarkRed) .success @include theme($theme: DarkGreen) CSS Output .info { background : DarkGray ; box-shadow : 0 0 1px rgba ( 169 , 169 , 169 , 0.25 ) ; color : #fff ; } .alert { background : DarkRed ; box-shadow : 0 0 1px rgba ( 139 , 0 , 0 , 0.25 ) ; color : #fff ; } .success { background : DarkGreen ; box-shadow : 0 0 1px rgba ( 0 , 100 , 0 , 0.25 ) ; color : #fff ; } To create a mixin you use the @mixin directive and give it a name. We’ve named our mixin theme . We’re also using the variable $theme inside the parentheses so we can pass in a theme of whatever we want. After you create your mixin, you can then use it as a CSS declaration starting with @include followed by the name of the   mixin. Extend/Inheritance Extend/Inheritance permalink Using @extend lets you share a set of CSS properties from one selector to another. In our example we’re going to create a simple series of messaging for errors, warnings and successes using another feature which goes hand in hand with extend, placeholder classes. A placeholder class is a special type of class that only prints when it is extended, and can help keep your compiled CSS neat and   clean. SCSS Sass CSS Playground SCSS Syntax /* This CSS will print because %message-shared is extended. */ %message-shared { border : 1px solid #ccc ; padding : 10px ; color : #333 ; } // This CSS won't print because %equal-heights is never extended. %equal-heights { display : flex ; flex-wrap : wrap ; } .message { @extend %message-shared ; } .success { @extend %message-shared ; border-color : green ; } .error { @extend %message-shared ; border-color : red ; } .warning { @extend %message-shared ; border-color : yellow ; } Playground Sass Syntax /* This CSS will print because %message-shared is extended. */ %message-shared border : 1px solid #ccc padding : 10px color : #333 // This CSS won't print because %equal-heights is never extended. %equal-heights display : flex flex-wrap : wrap .message @extend %message-shared .success @extend %message-shared border-color : green .error @extend %message-shared border-color : red .warning @extend %message-shared border-color : yellow CSS Output /* This CSS will print because %message-shared is extended. */ .warning, .error, .success, .message { border : 1px solid #ccc ; padding : 10px ; color : #333 ; } .success { border-color : green ; } .error { border-color : red ; } .warning { border-color : yellow ; } What the above code does is tells .message , .success , .error , and .warning to behave just like %message-shared . That means anywhere that %message-shared shows up, .message , .success , .error , & .warning will too. The magic happens in the generated CSS , where each of these classes will get the same CSS properties as %message-shared . This helps you avoid having to write multiple class names on HTML   elements. You can extend most simple CSS selectors in addition to placeholder classes in Sass, but using placeholders is the easiest way to make sure you aren’t extending a class that’s nested elsewhere in your styles, which can result in unintended selectors in your   CSS . Note that the CSS in %equal-heights isn’t generated, because %equal-heights is never   extended. Operators Operators permalink Doing math in your CSS is very helpful. Sass has a handful of standard math operators like + , - , * , math.div() , and % . In our example we’re going to do some simple math to calculate widths for an article and aside . SCSS Sass CSS Playground SCSS Syntax @use "sass:math" ; .container { display : flex ; } article[role="main"] { width : math. div ( 600px , 960px ) * 100% ; } aside[role="complementary"] { width : math. div ( 300px , 960px ) * 100% ; margin-left : auto ; } Playground Sass Syntax @use "sass:math" .container display : flex article[role="main"] width : math.div(600px, 960px) * 100 % aside[role="complementary"] width : math.div(300px, 960px) * 100 % margin-left : auto CSS Output .container { display : flex ; } article[role=main] { width : 62.5% ; } aside[role=complementary] { width : 31.25% ; margin-left : auto ; } We’ve created a very simple fluid grid, based on 960px. Operations in Sass let us do something like take pixel values and convert them to percentages without much   hassle.
Markdown
**Free Palestine** [![Sass](https://sass-lang.com/assets/img/logos/logo.svg)](https://sass-lang.com/) - [Playground](https://sass-lang.com/playground) - [Install](https://sass-lang.com/install) - [Learn Sass](https://sass-lang.com/guide) - [Blog](https://sass-lang.com/blog) - [Documentation](https://sass-lang.com/documentation) - [Get Involved](https://sass-lang.com/community) # Sass Basics ### Topics - [Preprocessing](https://sass-lang.com/guide/#preprocessing) - [Variables](https://sass-lang.com/guide/#variables) - [Nesting](https://sass-lang.com/guide/#nesting) - [Partials](https://sass-lang.com/guide/#partials) - [Modules](https://sass-lang.com/guide/#modules) - [Mixins](https://sass-lang.com/guide/#mixins) - [Inheritance](https://sass-lang.com/guide/#inheritance) - [Operators](https://sass-lang.com/guide/#operators) Before you can use Sass, you need to set it up on your project. If you want to just browse here, go ahead, but we recommend you go install Sass first. [Go here](https://sass-lang.com/install) if you want to learn how to get everything set up. ## Preprocessing[Preprocessing permalink](https://sass-lang.com/guide/#preprocessing) CSS on its own can be fun, but stylesheets are getting larger, more complex, and harder to maintain. This is where a preprocessor can help. Sass has features that don’t exist in CSS yet like nesting, mixins, inheritance, and other nifty goodies that help you write robust, maintainable CSS. Once you start tinkering with Sass, it will take your preprocessed Sass file and save it as a normal CSS file that you can use in your website. The most direct way to make this happen is in your terminal. Once Sass is installed, you can compile your Sass to CSS using the `sass` command. You’ll need to tell Sass which file to build from, and where to output CSS to. For example, running `sass input.scss output.css` from your terminal would take a single Sass file, `input.scss`, and compile that file to `output.css`. You can also watch individual files or directories with the `--watch` flag. The watch flag tells Sass to watch your source files for changes, and re-compile CSS each time you save your Sass. If you wanted to watch (instead of manually build) your `input.scss` file, you’d just add the watch flag to your command, like so: ``` sass --watch input.scss output.css ``` You can watch and output to directories by using folder paths as your input and output, and separating them with a colon. In this example: ``` sass --watch app/sass:public/stylesheets ``` Sass would watch all files in the `app/sass` folder for changes, and compile CSS to the `public/stylesheets` folder. ### 💡 Fun fact: Sass has two syntaxes! The SCSS syntax (`.scss`) is used most commonly. It’s a superset of CSS, which means all valid CSS is also valid SCSS. The indented syntax (`.sass`) is more unusual: it uses indentation rather than curly braces to nest statements, and newlines instead of semicolons to separate them. All our examples are available in both syntaxes. *** ## Variables[Variables permalink](https://sass-lang.com/guide/#variables) Think of variables as a way to store information that you want to reuse throughout your stylesheet. You can store things like colors, font stacks, or any CSS value you think you’ll want to reuse. Sass uses the `$` symbol to make something a variable. Here’s an example: - [SCSS](https://sass-lang.com/guide/#example-variables-scss) - [Sass](https://sass-lang.com/guide/#example-variables-sass) - [CSS](https://sass-lang.com/guide/#example-variables-css) [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJwzNFRJy88r0S0uSUzOtlLwSM0pSy3JTE7UUShOzCvWLU4tykyz5lIpKMrMTSyq1E3Oz8kvslJQNjY2tubiSspPqVSo5lJQABlhpWBoYKCqgGScNVAGqgHVAGuuWgA2kiah) ### SCSS Syntax ``` $font-stack: Helvetica, sans-serif; $primary-color: #333; body { font: 100% $font-stack; color: $primary-color; } ``` [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJwzMFRJy88r0S0uSUzOtlLwSM0pSy3JTE7UUShOzCvWLU4tykzjUikoysxNLKrUTc7PyS+yUlA2Njbm4krKT6nkUlAAabdSMDQwUFVAMgooAVWMqhkAF7Qkkg==) ### Sass Syntax ``` $font-stack: Helvetica, sans-serif $primary-color: #333 body font: 100% $font-stack color: $primary-color ``` ### CSS Output ``` body { font: 100% Helvetica, sans-serif; color: #333; } ``` When the Sass is processed, it takes the variables we define for the `$font-stack` and `$primary-color` and outputs normal CSS with our variable values placed in the CSS. This can be extremely powerful when working with brand colors and keeping them consistent throughout the site. *** ## Nesting[Nesting permalink](https://sass-lang.com/guide/#nesting) When writing HTML you’ve probably noticed that it has a clear nested and visual hierarchy. CSS, on the other hand, doesn’t. Sass will let you nest your CSS selectors in a way that follows the same visual hierarchy of your HTML. Be aware that overly nested rules will result in over-qualified CSS that could prove hard to maintain and is generally considered bad practice. With that in mind, here’s an example of some typical styles for a site’s navigation: - [SCSS](https://sass-lang.com/guide/#example-nesting-scss) - [Sass](https://sass-lang.com/guide/#example-nesting-sass) - [CSS](https://sass-lang.com/guide/#example-nesting-css) [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJxVjUEKwjAURPc5xVwgYFy4SE/zbUL5+P0JTZSU0rtLGym6GmbewHNO6Y3VAC85AnjSPLF6XIajZgqBdTq7cKm21EWihyaN+7oZswOsCFyy0OLBKqzR3iWNj6Ef6Cs4Px3+W265wV1z63ONrdoQxzRT5aS/xu0DeoU2lQ==) ### SCSS Syntax ``` nav { ul { margin: 0; padding: 0; list-style: none; } li { display: inline-block; } a { display: block; padding: 6px 12px; text-decoration: none; } } ``` [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJxVjUEKhDAMRfc9RS5QUBcuepuMDRLMpMVmhnp7teKimw//Pfh/GBX/DuAnVwB8cV9ZAwytZYyRdX2rcDFf7BAKoEnJuZs1FblkwSMAq7CS/0hatttjrx/ebc+5wjjl2qhRNR9pSTsaJ31+TtSwMEM=) ### Sass Syntax ``` nav ul margin: 0 padding: 0 list-style: none li display: inline-block a display: block padding: 6px 12px text-decoration: none ``` ### CSS Output ``` nav ul { margin: 0; padding: 0; list-style: none; } nav li { display: inline-block; } nav a { display: block; padding: 6px 12px; text-decoration: none; } ``` You’ll notice that the `ul`, `li`, and `a` selectors are nested inside the `nav` selector. This is a great way to organize your CSS and make it more readable. *** ## Partials[Partials permalink](https://sass-lang.com/guide/#partials) You can create partial Sass files that contain little snippets of CSS that you can include in other Sass files. This is a great way to modularize your CSS and help keep things easier to maintain. A partial is a Sass file named with a leading underscore. You might name it something like `_partial.scss`. The underscore lets Sass know that the file is only a partial file and that it should not be generated into a CSS file. Sass partials are used with the `@use` rule. *** ## Modules[Modules permalink](https://sass-lang.com/guide/#modules) Compatibility: Dart Sass since 1.23.0 LibSass ✗ Ruby Sass ✗ [➤]() Only Dart Sass currently supports `@use`. Users of other implementations must use the [`@import` rule](https://sass-lang.com/documentation/at-rules/import) instead. You don’t have to write all your Sass in a single file. You can split it up however you want with the `@use` rule. This rule loads another Sass file as a *module*, which means you can refer to its variables, [mixins](https://sass-lang.com/guide/#mixins), and [functions](https://sass-lang.com/documentation/at-rules/function) in your Sass file with a namespace based on the filename. Using a file will also include the CSS it generates in your compiled output\! - [SCSS](https://sass-lang.com/guide/#example-modules-scss) - [Sass](https://sass-lang.com/guide/#example-modules-sass) - [CSS](https://sass-lang.com/guide/#example-modules-css) ### SCSS Syntax ``` // _base.scss $font-stack: Helvetica, sans-serif; $primary-color: #333; body { font: 100% $font-stack; color: $primary-color; } ``` ``` // styles.scss @use 'base'; .inverse { background-color: base.$primary-color; color: white; } ``` ### Sass Syntax ``` // _base.sass $font-stack: Helvetica, sans-serif $primary-color: #333 body font: 100% $font-stack color: $primary-color ``` ``` // styles.sass @use 'base' .inverse background-color: base.$primary-color color: white ``` ### CSS Output ``` body { font: 100% Helvetica, sans-serif; color: #333; } .inverse { background-color: #333; color: white; } ``` Notice we’re using `@use 'base';` in the `styles.scss` file. When you use a file you don’t need to include the file extension. Sass is smart and will figure it out for you. *** ## Mixins[Mixins permalink](https://sass-lang.com/guide/#mixins) Some things in CSS are a bit tedious to write, especially with CSS3 and the many vendor prefixes that exist. A mixin lets you make groups of CSS declarations that you want to reuse throughout your site. It helps keep your Sass very DRY. You can even pass in values to make your mixin more flexible. Here’s an example for `theme`. - [SCSS](https://sass-lang.com/guide/#example-mixins-scss) - [Sass](https://sass-lang.com/guide/#example-mixins-sass) - [CSS](https://sass-lang.com/guide/#example-mixins-css) [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJyFjrEKwjAQhvc8xYEOFjRYwSVdOgjdfYM0ubShbSKXBivSd9fGLoIgNxz89/0fl+flYCfrYGxxwN02LQEXSV1F8pHBkwHUUnUN+ei0gA9RLKmfDqGV2t8FHN+T3yagpparZA/8dM4WUPnek4CNMaZgM2PcOuOTuLRO9VEjrNKZcdkjjT+OX69dUWeJDlEpDOEfXxGiWxovNV1Lkw==) ### SCSS Syntax ``` @mixin theme($theme: DarkGray) { background: $theme; box-shadow: 0 0 1px rgba($theme, .25); color: #fff; } .info { @include theme; } .alert { @include theme($theme: DarkRed); } .success { @include theme($theme: DarkGreen); } ``` [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJwzMHTIzazIzFMoyUjNTdVQAVNWCi6JRdnuRYmVmlwKCkmJydnpRfmleSlWChB5kGB+hW5xRmJKfrmVggEQGhZUKBSlJyVCTdBR0DMyBWlOzs/JL7JSUE5LS+Pi0svMS8sHCjpk5iXnlKakQiwFiifmpBaVYEiguCYoNUUTqLK4NDk5tbgYv1r3otTUPE0AvxxFvA==) ### Sass Syntax ``` @mixin theme($theme: DarkGray) background: $theme box-shadow: 0 0 1px rgba($theme, .25) color: #fff .info @include theme .alert @include theme($theme: DarkRed) .success @include theme($theme: DarkGreen) ``` ### CSS Output ``` .info { background: DarkGray; box-shadow: 0 0 1px rgba(169, 169, 169, 0.25); color: #fff; } .alert { background: DarkRed; box-shadow: 0 0 1px rgba(139, 0, 0, 0.25); color: #fff; } .success { background: DarkGreen; box-shadow: 0 0 1px rgba(0, 100, 0, 0.25); color: #fff; } ``` To create a mixin you use the `@mixin` directive and give it a name. We’ve named our mixin `theme`. We’re also using the variable `$theme` inside the parentheses so we can pass in a `theme` of whatever we want. After you create your mixin, you can then use it as a CSS declaration starting with `@include` followed by the name of the mixin. *** ## Extend/Inheritance[Extend/Inheritance permalink](https://sass-lang.com/guide/#extend-inheritance) Using `@extend` lets you share a set of CSS properties from one selector to another. In our example we’re going to create a simple series of messaging for errors, warnings and successes using another feature which goes hand in hand with extend, placeholder classes. A placeholder class is a special type of class that only prints when it is extended, and can help keep your compiled CSS neat and clean. - [SCSS](https://sass-lang.com/guide/#example-extend-inheritance-scss) - [Sass](https://sass-lang.com/guide/#example-extend-inheritance-sass) - [CSS](https://sass-lang.com/guide/#example-extend-inheritance-css) [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJyVUEFqwzAQvOsVC6EUAo5rfHMuhT4h/YAibWzBVlJ37dqh9O+V7KQNPgRykWBnZmdmq6rcwnvnBN4OBxgdEUR2vocjGj0IwtMHiugWC+k0o4XExKlHb9HuYFuqNf6tAI6BLXIDVZxAAjkLG2PMPiFRW+t8m6CXOOWBCRQSc1PX9V79KFWWN2mCf+7XcfBz0FR06Nqul5zG4xfyfya1YuQ81kkkfW7gRDi75r8YWccG8js77y5FZsXrsm/dfiHKYEwa3yder1BcGraM6Bc9Mgd+TP3nPWr26YCPqc9IFMa04BeaM6IW) ### SCSS Syntax ``` /* This CSS will print because %message-shared is extended. */ %message-shared { border: 1px solid #ccc; padding: 10px; color: #333; } // This CSS won't print because %equal-heights is never extended. %equal-heights { display: flex; flex-wrap: wrap; } .message { @extend %message-shared; } .success { @extend %message-shared; border-color: green; } .error { @extend %message-shared; border-color: red; } .warning { @extend %message-shared; border-color: yellow; } ``` [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJyVUEFqwzAQvOsVCyEUAo4TfPOp0CekH1CkqS3YSsrKrp3fZ01S2vpQyEWLdmZ2Z/ZwrHf03odCb6cTTYGZsoQ40BnOjgW0/UQptkNVeivwpEzMA6KH39OuNivcEJ2TeEhLxzxTSRw8bZxzCmTrfYidIoc8698lTsrbNE1jTF3/spHiy7D2gctoueoRun4oi42IL8iPGfOXofN9KJnttaUPxrJvKdUkNre0vMbsH94Ve73PWcdVThmd094/nO/I1SNQJ0BUJUSSPKG775usRL3SE7ormNN0AxfumIU=) ### Sass Syntax ``` /* This CSS will print because %message-shared is extended. */ %message-shared border: 1px solid #ccc padding: 10px color: #333 // This CSS won't print because %equal-heights is never extended. %equal-heights display: flex flex-wrap: wrap .message @extend %message-shared .success @extend %message-shared border-color: green .error @extend %message-shared border-color: red .warning @extend %message-shared border-color: yellow ``` ### CSS Output ``` /* This CSS will print because %message-shared is extended. */ .warning, .error, .success, .message { border: 1px solid #ccc; padding: 10px; color: #333; } .success { border-color: green; } .error { border-color: red; } .warning { border-color: yellow; } ``` What the above code does is tells `.message`, `.success`, `.error`, and `.warning` to behave just like `%message-shared`. That means anywhere that `%message-shared` shows up, `.message`, `.success`, `.error`, & `.warning` will too. The magic happens in the generated CSS, where each of these classes will get the same CSS properties as `%message-shared`. This helps you avoid having to write multiple class names on HTML elements. You can extend most simple CSS selectors in addition to placeholder classes in Sass, but using placeholders is the easiest way to make sure you aren’t extending a class that’s nested elsewhere in your styles, which can result in unintended selectors in your CSS. Note that the CSS in `%equal-heights` isn’t generated, because `%equal-heights` is never extended. *** ## Operators[Operators permalink](https://sass-lang.com/guide/#operators) Doing math in your CSS is very helpful. Sass has a handful of standard math operators like `+`, `-`, `*`, `math.div()`, and `%`. In our example we’re going to do some simple math to calculate widths for an `article` and `aside`. - [SCSS](https://sass-lang.com/guide/#example-operators-scss) - [Sass](https://sass-lang.com/guide/#example-operators-sass) - [CSS](https://sass-lang.com/guide/#example-operators-css) [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJx1zUEKwjAQheF9TjEEBBUtCULBFMF7iIuQTO1A0pQk1Rbx7kbFna5m88/3pDyOCYEnnZLyOne8Yawyoc+aeoxwZwCW0uD0rKB1ODXswZiOmYzDUwwOD9yXlJ/f6Y1s7hS8oMrSdVkLMUwb2NflrGANUojFR0hkv/8m+MGhx7IZ5z/Q7icEJYgX6rcO26xAjzkU/QnQWUHM) ### SCSS Syntax ``` @use "sass:math"; .container { display: flex; } article[role="main"] { width: math.div(600px, 960px) * 100%; } aside[role="complementary"] { width: math.div(300px, 960px) * 100%; margin-left: auto; } ``` [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJxtjc0KwjAQhO95iiUgqGhJEQoGBN9DPCzJ1i7kjyTV9u2NB289zWHm+0b197kQyIKlaI91kkJ0JoaKHCgLAMslOVw1jI4WITBXNo4eOTq6Sd9W8tlWH7Z10vATdJbf+0GptJzgOrQ4wBF6pXYNLmz/qIk+OfLUnvK66bhsOaD1+cXh7GisGnCu8QvSOz0+) ### Sass Syntax ``` @use "sass:math" .container display: flex article[role="main"] width: math.div(600px, 960px) * 100% aside[role="complementary"] width: math.div(300px, 960px) * 100% margin-left: auto ``` ### CSS Output ``` .container { display: flex; } article[role=main] { width: 62.5%; } aside[role=complementary] { width: 31.25%; margin-left: auto; } ``` We’ve created a very simple fluid grid, based on 960px. Operations in Sass let us do something like take pixel values and convert them to percentages without much hassle. - Current Releases: - [Dart Sass](https://sass-lang.com/dart-sass) [1\.99.0](https://github.com/sass/dart-sass/releases/tag/1.99.0) - [LibSass](https://sass-lang.com/libsass) ⚰ - [Ruby Sass](https://sass-lang.com/ruby-sass) ⚰ - [Implementation Guide](https://sass-lang.com/implementation) Sass © 2006–2026 the Sass team, and numerous contributors. It is available for use and modification under the [MIT License](https://github.com/sass/dart-sass/blob/main/LICENSE). - [Sass on GitHub](https://github.com/sass) - [Website Source Code](https://github.com/sass/sass-site) - [Style Guide](https://sass-lang.com/styleguide) - [Community Guidelines](https://sass-lang.com/community-guidelines) [@sass@front-end.social](https://front-end.social/@sass) [![Deploys by Netlify](https://www.netlify.com/v3/img/components/netlify-color-bg.svg)](https://www.netlify.com/)
Readable Markdown
Before you can use Sass, you need to set it up on your project. If you want to just browse here, go ahead, but we recommend you go install Sass first. [Go here](https://sass-lang.com/install) if you want to learn how to get everything set up. ## Preprocessing[Preprocessing permalink](https://sass-lang.com/guide/#preprocessing) CSS on its own can be fun, but stylesheets are getting larger, more complex, and harder to maintain. This is where a preprocessor can help. Sass has features that don’t exist in CSS yet like nesting, mixins, inheritance, and other nifty goodies that help you write robust, maintainable CSS. Once you start tinkering with Sass, it will take your preprocessed Sass file and save it as a normal CSS file that you can use in your website. The most direct way to make this happen is in your terminal. Once Sass is installed, you can compile your Sass to CSS using the `sass` command. You’ll need to tell Sass which file to build from, and where to output CSS to. For example, running `sass input.scss output.css` from your terminal would take a single Sass file, `input.scss`, and compile that file to `output.css`. You can also watch individual files or directories with the `--watch` flag. The watch flag tells Sass to watch your source files for changes, and re-compile CSS each time you save your Sass. If you wanted to watch (instead of manually build) your `input.scss` file, you’d just add the watch flag to your command, like so: ``` sass --watch input.scss output.css ``` You can watch and output to directories by using folder paths as your input and output, and separating them with a colon. In this example: ``` sass --watch app/sass:public/stylesheets ``` Sass would watch all files in the `app/sass` folder for changes, and compile CSS to the `public/stylesheets` folder. ### 💡 Fun fact: Sass has two syntaxes! The SCSS syntax (`.scss`) is used most commonly. It’s a superset of CSS, which means all valid CSS is also valid SCSS. The indented syntax (`.sass`) is more unusual: it uses indentation rather than curly braces to nest statements, and newlines instead of semicolons to separate them. All our examples are available in both syntaxes. *** ## Variables[Variables permalink](https://sass-lang.com/guide/#variables) Think of variables as a way to store information that you want to reuse throughout your stylesheet. You can store things like colors, font stacks, or any CSS value you think you’ll want to reuse. Sass uses the `$` symbol to make something a variable. Here’s an example: - [SCSS](https://sass-lang.com/guide/#example-variables-scss) - [Sass](https://sass-lang.com/guide/#example-variables-sass) - [CSS](https://sass-lang.com/guide/#example-variables-css) [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJwzNFRJy88r0S0uSUzOtlLwSM0pSy3JTE7UUShOzCvWLU4tykyz5lIpKMrMTSyq1E3Oz8kvslJQNjY2tubiSspPqVSo5lJQABlhpWBoYKCqgGScNVAGqgHVAGuuWgA2kiah) ### SCSS Syntax ``` $font-stack: Helvetica, sans-serif; $primary-color: #333; body { font: 100% $font-stack; color: $primary-color; } ``` [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJwzMFRJy88r0S0uSUzOtlLwSM0pSy3JTE7UUShOzCvWLU4tykzjUikoysxNLKrUTc7PyS+yUlA2Njbm4krKT6nkUlAAabdSMDQwUFVAMgooAVWMqhkAF7Qkkg==) ### Sass Syntax ``` $font-stack: Helvetica, sans-serif $primary-color: #333 body font: 100% $font-stack color: $primary-color ``` ### CSS Output ``` body { font: 100% Helvetica, sans-serif; color: #333; } ``` When the Sass is processed, it takes the variables we define for the `$font-stack` and `$primary-color` and outputs normal CSS with our variable values placed in the CSS. This can be extremely powerful when working with brand colors and keeping them consistent throughout the site. *** ## Nesting[Nesting permalink](https://sass-lang.com/guide/#nesting) When writing HTML you’ve probably noticed that it has a clear nested and visual hierarchy. CSS, on the other hand, doesn’t. Sass will let you nest your CSS selectors in a way that follows the same visual hierarchy of your HTML. Be aware that overly nested rules will result in over-qualified CSS that could prove hard to maintain and is generally considered bad practice. With that in mind, here’s an example of some typical styles for a site’s navigation: - [SCSS](https://sass-lang.com/guide/#example-nesting-scss) - [Sass](https://sass-lang.com/guide/#example-nesting-sass) - [CSS](https://sass-lang.com/guide/#example-nesting-css) [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJxVjUEKwjAURPc5xVwgYFy4SE/zbUL5+P0JTZSU0rtLGym6GmbewHNO6Y3VAC85AnjSPLF6XIajZgqBdTq7cKm21EWihyaN+7oZswOsCFyy0OLBKqzR3iWNj6Ef6Cs4Px3+W265wV1z63ONrdoQxzRT5aS/xu0DeoU2lQ==) ### SCSS Syntax ``` nav { ul { margin: 0; padding: 0; list-style: none; } li { display: inline-block; } a { display: block; padding: 6px 12px; text-decoration: none; } } ``` [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJxVjUEKhDAMRfc9RS5QUBcuepuMDRLMpMVmhnp7teKimw//Pfh/GBX/DuAnVwB8cV9ZAwytZYyRdX2rcDFf7BAKoEnJuZs1FblkwSMAq7CS/0hatttjrx/ebc+5wjjl2qhRNR9pSTsaJ31+TtSwMEM=) ### Sass Syntax ``` nav ul margin: 0 padding: 0 list-style: none li display: inline-block a display: block padding: 6px 12px text-decoration: none ``` ### CSS Output ``` nav ul { margin: 0; padding: 0; list-style: none; } nav li { display: inline-block; } nav a { display: block; padding: 6px 12px; text-decoration: none; } ``` You’ll notice that the `ul`, `li`, and `a` selectors are nested inside the `nav` selector. This is a great way to organize your CSS and make it more readable. *** ## Partials[Partials permalink](https://sass-lang.com/guide/#partials) You can create partial Sass files that contain little snippets of CSS that you can include in other Sass files. This is a great way to modularize your CSS and help keep things easier to maintain. A partial is a Sass file named with a leading underscore. You might name it something like `_partial.scss`. The underscore lets Sass know that the file is only a partial file and that it should not be generated into a CSS file. Sass partials are used with the `@use` rule. *** ## Modules[Modules permalink](https://sass-lang.com/guide/#modules) Compatibility: Dart Sasssince 1.23.0 LibSass✗ Ruby Sass✗ Only Dart Sass currently supports `@use`. Users of other implementations must use the [`@import` rule](https://sass-lang.com/documentation/at-rules/import) instead. You don’t have to write all your Sass in a single file. You can split it up however you want with the `@use` rule. This rule loads another Sass file as a *module*, which means you can refer to its variables, [mixins](https://sass-lang.com/guide/#mixins), and [functions](https://sass-lang.com/documentation/at-rules/function) in your Sass file with a namespace based on the filename. Using a file will also include the CSS it generates in your compiled output\! - [SCSS](https://sass-lang.com/guide/#example-modules-scss) - [Sass](https://sass-lang.com/guide/#example-modules-sass) - [CSS](https://sass-lang.com/guide/#example-modules-css) ### SCSS Syntax ``` // _base.scss $font-stack: Helvetica, sans-serif; $primary-color: #333; body { font: 100% $font-stack; color: $primary-color; } ``` ``` // styles.scss @use 'base'; .inverse { background-color: base.$primary-color; color: white; } ``` ### Sass Syntax ``` // _base.sass $font-stack: Helvetica, sans-serif $primary-color: #333 body font: 100% $font-stack color: $primary-color ``` ``` // styles.sass @use 'base' .inverse background-color: base.$primary-color color: white ``` ### CSS Output ``` body { font: 100% Helvetica, sans-serif; color: #333; } .inverse { background-color: #333; color: white; } ``` Notice we’re using `@use 'base';` in the `styles.scss` file. When you use a file you don’t need to include the file extension. Sass is smart and will figure it out for you. *** ## Mixins[Mixins permalink](https://sass-lang.com/guide/#mixins) Some things in CSS are a bit tedious to write, especially with CSS3 and the many vendor prefixes that exist. A mixin lets you make groups of CSS declarations that you want to reuse throughout your site. It helps keep your Sass very DRY. You can even pass in values to make your mixin more flexible. Here’s an example for `theme`. - [SCSS](https://sass-lang.com/guide/#example-mixins-scss) - [Sass](https://sass-lang.com/guide/#example-mixins-sass) - [CSS](https://sass-lang.com/guide/#example-mixins-css) [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJyFjrEKwjAQhvc8xYEOFjRYwSVdOgjdfYM0ubShbSKXBivSd9fGLoIgNxz89/0fl+flYCfrYGxxwN02LQEXSV1F8pHBkwHUUnUN+ei0gA9RLKmfDqGV2t8FHN+T3yagpparZA/8dM4WUPnek4CNMaZgM2PcOuOTuLRO9VEjrNKZcdkjjT+OX69dUWeJDlEpDOEfXxGiWxovNV1Lkw==) ### SCSS Syntax ``` @mixin theme($theme: DarkGray) { background: $theme; box-shadow: 0 0 1px rgba($theme, .25); color: #fff; } .info { @include theme; } .alert { @include theme($theme: DarkRed); } .success { @include theme($theme: DarkGreen); } ``` [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJwzMHTIzazIzFMoyUjNTdVQAVNWCi6JRdnuRYmVmlwKCkmJydnpRfmleSlWChB5kGB+hW5xRmJKfrmVggEQGhZUKBSlJyVCTdBR0DMyBWlOzs/JL7JSUE5LS+Pi0svMS8sHCjpk5iXnlKakQiwFiifmpBaVYEiguCYoNUUTqLK4NDk5tbgYv1r3otTUPE0AvxxFvA==) ### Sass Syntax ``` @mixin theme($theme: DarkGray) background: $theme box-shadow: 0 0 1px rgba($theme, .25) color: #fff .info @include theme .alert @include theme($theme: DarkRed) .success @include theme($theme: DarkGreen) ``` ### CSS Output ``` .info { background: DarkGray; box-shadow: 0 0 1px rgba(169, 169, 169, 0.25); color: #fff; } .alert { background: DarkRed; box-shadow: 0 0 1px rgba(139, 0, 0, 0.25); color: #fff; } .success { background: DarkGreen; box-shadow: 0 0 1px rgba(0, 100, 0, 0.25); color: #fff; } ``` To create a mixin you use the `@mixin` directive and give it a name. We’ve named our mixin `theme`. We’re also using the variable `$theme` inside the parentheses so we can pass in a `theme` of whatever we want. After you create your mixin, you can then use it as a CSS declaration starting with `@include` followed by the name of the mixin. *** ## Extend/Inheritance[Extend/Inheritance permalink](https://sass-lang.com/guide/#extend-inheritance) Using `@extend` lets you share a set of CSS properties from one selector to another. In our example we’re going to create a simple series of messaging for errors, warnings and successes using another feature which goes hand in hand with extend, placeholder classes. A placeholder class is a special type of class that only prints when it is extended, and can help keep your compiled CSS neat and clean. - [SCSS](https://sass-lang.com/guide/#example-extend-inheritance-scss) - [Sass](https://sass-lang.com/guide/#example-extend-inheritance-sass) - [CSS](https://sass-lang.com/guide/#example-extend-inheritance-css) [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJyVUEFqwzAQvOsVC6EUAo5rfHMuhT4h/YAibWzBVlJ37dqh9O+V7KQNPgRykWBnZmdmq6rcwnvnBN4OBxgdEUR2vocjGj0IwtMHiugWC+k0o4XExKlHb9HuYFuqNf6tAI6BLXIDVZxAAjkLG2PMPiFRW+t8m6CXOOWBCRQSc1PX9V79KFWWN2mCf+7XcfBz0FR06Nqul5zG4xfyfya1YuQ81kkkfW7gRDi75r8YWccG8js77y5FZsXrsm/dfiHKYEwa3yder1BcGraM6Bc9Mgd+TP3nPWr26YCPqc9IFMa04BeaM6IW) ### SCSS Syntax ``` /* This CSS will print because %message-shared is extended. */ %message-shared { border: 1px solid #ccc; padding: 10px; color: #333; } // This CSS won't print because %equal-heights is never extended. %equal-heights { display: flex; flex-wrap: wrap; } .message { @extend %message-shared; } .success { @extend %message-shared; border-color: green; } .error { @extend %message-shared; border-color: red; } .warning { @extend %message-shared; border-color: yellow; } ``` [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJyVUEFqwzAQvOsVCyEUAo4TfPOp0CekH1CkqS3YSsrKrp3fZ01S2vpQyEWLdmZ2Z/ZwrHf03odCb6cTTYGZsoQ40BnOjgW0/UQptkNVeivwpEzMA6KH39OuNivcEJ2TeEhLxzxTSRw8bZxzCmTrfYidIoc8698lTsrbNE1jTF3/spHiy7D2gctoueoRun4oi42IL8iPGfOXofN9KJnttaUPxrJvKdUkNre0vMbsH94Ve73PWcdVThmd094/nO/I1SNQJ0BUJUSSPKG775usRL3SE7ormNN0AxfumIU=) ### Sass Syntax ``` /* This CSS will print because %message-shared is extended. */ %message-shared border: 1px solid #ccc padding: 10px color: #333 // This CSS won't print because %equal-heights is never extended. %equal-heights display: flex flex-wrap: wrap .message @extend %message-shared .success @extend %message-shared border-color: green .error @extend %message-shared border-color: red .warning @extend %message-shared border-color: yellow ``` ### CSS Output ``` /* This CSS will print because %message-shared is extended. */ .warning, .error, .success, .message { border: 1px solid #ccc; padding: 10px; color: #333; } .success { border-color: green; } .error { border-color: red; } .warning { border-color: yellow; } ``` What the above code does is tells `.message`, `.success`, `.error`, and `.warning` to behave just like `%message-shared`. That means anywhere that `%message-shared` shows up, `.message`, `.success`, `.error`, & `.warning` will too. The magic happens in the generated CSS, where each of these classes will get the same CSS properties as `%message-shared`. This helps you avoid having to write multiple class names on HTML elements. You can extend most simple CSS selectors in addition to placeholder classes in Sass, but using placeholders is the easiest way to make sure you aren’t extending a class that’s nested elsewhere in your styles, which can result in unintended selectors in your CSS. Note that the CSS in `%equal-heights` isn’t generated, because `%equal-heights` is never extended. *** ## Operators[Operators permalink](https://sass-lang.com/guide/#operators) Doing math in your CSS is very helpful. Sass has a handful of standard math operators like `+`, `-`, `*`, `math.div()`, and `%`. In our example we’re going to do some simple math to calculate widths for an `article` and `aside`. - [SCSS](https://sass-lang.com/guide/#example-operators-scss) - [Sass](https://sass-lang.com/guide/#example-operators-sass) - [CSS](https://sass-lang.com/guide/#example-operators-css) [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJx1zUEKwjAQheF9TjEEBBUtCULBFMF7iIuQTO1A0pQk1Rbx7kbFna5m88/3pDyOCYEnnZLyOne8Yawyoc+aeoxwZwCW0uD0rKB1ODXswZiOmYzDUwwOD9yXlJ/f6Y1s7hS8oMrSdVkLMUwb2NflrGANUojFR0hkv/8m+MGhx7IZ5z/Q7icEJYgX6rcO26xAjzkU/QnQWUHM) ### SCSS Syntax ``` @use "sass:math"; .container { display: flex; } article[role="main"] { width: math.div(600px, 960px) * 100%; } aside[role="complementary"] { width: math.div(300px, 960px) * 100%; margin-left: auto; } ``` [![Sass](https://sass-lang.com/assets/img/logos/logo.svg) Playground](https://sass-lang.com/playground#eJxtjc0KwjAQhO95iiUgqGhJEQoGBN9DPCzJ1i7kjyTV9u2NB289zWHm+0b197kQyIKlaI91kkJ0JoaKHCgLAMslOVw1jI4WITBXNo4eOTq6Sd9W8tlWH7Z10vATdJbf+0GptJzgOrQ4wBF6pXYNLmz/qIk+OfLUnvK66bhsOaD1+cXh7GisGnCu8QvSOz0+) ### Sass Syntax ``` @use "sass:math" .container display: flex article[role="main"] width: math.div(600px, 960px) * 100% aside[role="complementary"] width: math.div(300px, 960px) * 100% margin-left: auto ``` ### CSS Output ``` .container { display: flex; } article[role=main] { width: 62.5%; } aside[role=complementary] { width: 31.25%; margin-left: auto; } ``` We’ve created a very simple fluid grid, based on 960px. Operations in Sass let us do something like take pixel values and convert them to percentages without much hassle.
Shard112 (laksa)
Root Hash7297080260423426912
Unparsed URLcom,sass-lang!/guide/ s443