CSS preprocessor
CSS-препроцессор
A tool that turns an extended stylesheet language into regular CSS. It lets developers reuse values and groups of declarations while sending the browser CSS it can read directly.
Also known as: Sass, SCSS, Less
What a preprocessor does
A CSS preprocessor changes how you write styles, not how the browser applies them. You edit source files that can contain features like reusable snippets with parameters. The preprocessor translates those files into CSS, and the browser applies its usual rules for the cascade and selector specificity.
Sass and Less are two different options. SCSS is a syntax for Sass, not a separate preprocessor. It uses braces and semicolons, so it looks familiar to anyone who has written CSS. The other Sass syntax, used in .sass files, uses indentation instead of braces. Less has its own language and typically uses .less files.
From source file to stylesheet
Compilation usually runs as a command or as part of the build pipeline. A Sass compiler can resolve variables, expand nested selectors, and insert declarations from a mixin, a reusable block that can take arguments. Sass also lets you load modules with @use so different stylesheets can share values, functions, and mixins. When source maps are enabled, browser developer tools can point you back to the original SCSS rather than just a line in the generated stylesheet.
Example: two sizes from one mixin
@mixin pill($padding) {
border-radius: 999px;
padding: $padding;
}
.badge { @include pill(4px); }
.tag { @include pill(8px); }
The compiled .badge rule contains border-radius: 999px and padding: 4px; .tag gets the same radius and padding: 8px. The mixin saves you from maintaining the pattern in two source files or rules, but its declarations appear in both output rules. Less source code does not necessarily mean less CSS for the browser to download.
When to use one
Preprocessors are common in established codebases and design systems that share styling patterns across components. For a new project, check what you need before adding a build dependency: modern CSS already offers custom properties and native nesting. Also watch what your nested Sass rules produce. Several levels of nested class selectors can generate rules with higher specificity that are harder to override.
What interviewers ask
A common question is whether a Sass variable and a CSS custom property are interchangeable. A Sass variable such as $accent is resolved at build time. A CSS custom property such as --accent stays in the stylesheet, participates in the cascade, and is read with var(--accent). If a dark-mode class should change a color without rebuilding the site, define the color as a custom property and override it under that class.