Before you begin
Learn CSS selectors, the box model and responsive rules first. SCSS extends CSS authoring; it does not replace understanding CSS.
Learn Sass and SCSS step by step: store design values, reuse style patterns, split code into modules, and compile your work into browser-ready CSS. Every module explains the idea in plain language, walks through a code example and gives you a small task to try yourself.
Learn CSS selectors, the box model and responsive rules first. SCSS extends CSS authoring; it does not replace understanding CSS.
Structure a small design system with reusable Sass modules and produce readable, browser-ready CSS.
Work through the modules in order if you’re new to Sass / SCSS. If you already know the basics, use the contents list to jump to a topic. Try each example by changing one value, running it again and explaining the result in your own words.
Sass adds features that help you organize stylesheets, then compiles them into regular CSS. SCSS is the Sass syntax that looks most like the CSS you already know, so ordinary CSS rules can usually go straight into an .scss file. Browsers do not read SCSS directly; a compiler such as Dart Sass turns it into a .css file the browser can load. Think of SCSS as the source recipe and CSS as the finished dish.
$brand: #245f4a;
.button {
background: $brand;
color: white;
}Sass variables store compile-time values and are useful for values you configure before building CSS. CSS custom properties remain available in the browser and can change at runtime. Use the right tool for the job: a Sass map for build-time token sets, a custom property for runtime theming.
$space: 1rem;
$brand: #245f4a;
:root { --brand: #{$brand}; }
.card { padding: $space; color: var(--brand); }Nesting places related rules together, and & refers to the current parent selector for states or modifiers. Keep nesting shallow: deeply nested rules generate long selectors that are harder to override. Nest related selectors only when it improves readability.
.button {
padding: 0.75rem 1rem;
&:hover { filter: brightness(0.95); }
&--quiet { background: transparent; }
}Split large stylesheets into small files named with a leading underscore; these partials are not emitted as standalone CSS. Load and share public Sass APIs with @use and @forward. The older Sass @import rule is deprecated; move code toward modules instead of starting new projects with imports.
// _tokens.scss
$brand: #245f4a;
// styles.scss
@use 'tokens';
.page-title { color: tokens.$brand; }A mixin inserts a reusable block of CSS declarations and can accept parameters or content. Use it when several components share a genuine pattern, not merely to give every rule a new name. Check the compiled output to avoid duplicating large blocks unnecessarily.
@mixin focus-ring($color) {
&:focus-visible { outline: 3px solid $color; outline-offset: 3px; }
}
.button { @include focus-ring(#245f4a); }Functions return a value for use in another expression; maps group related key-value settings. Prefer Sass’s built-in module functions through @use "sass:map" and @use "sass:color" instead of deprecated global helpers. Validate that a requested map key exists so mistakes fail clearly.
@use 'sass:map';
$colors: ('brand': #245f4a, 'ink': #182538);
$brand: map.get($colors, 'brand');
.badge { color: $brand; }Control directives such as @each, @for and @if generate CSS based on data. They can help produce a family of utilities, but broad generation can bloat stylesheets. Generate only classes your design system needs and inspect the output before shipping.
$spaces: (1: .25rem, 2: .5rem, 3: 1rem);
@each $key, $value in $spaces {
.gap-#{$key} { gap: $value; }
}Use Sass to organize source and CSS custom properties when a value should respond to runtime themes or component state. Media queries can be written in nested component context; keep breakpoints consistent and consider the content rather than specific devices.
$card-padding: 1rem;
.card {
padding: $card-padding;
@media (min-width: 48rem) { padding: $card-padding * 1.5; }
}Run Dart Sass in watch mode while authoring and use source maps during development when available. Compile in CI or the build pipeline so deployed pages receive CSS. Treat compiler warnings as migration signals, and do not ship Sass source maps if they expose private source or paths.
# One-time compilation
sass src/scss:public/css
# Recompile when source files change
sass --watch src/scss:public/cssBuild a small Sass design system with token modules, reusable component mixins and generated CSS utilities. Write down what the project should do, build it in small steps, and include a README that explains how to run it.
Find a guided course →Use primary documentation for current language rules and version changes. The examples in this guide are learning starting points; verify details for the exact runtime and browser support your project needs.
SCSS is one syntax supported by Sass. The indented .sass syntax is the other; both compile to CSS.
No. Compile SCSS to CSS before serving it to the browser.