Skip to content
BENIBIX Learn

Sass Variables vs CSS Custom Properties

People think Sass variables and CSS custom properties are the same thing, and they are not. A Sass variable, like $brand, is used up when the Sass turns into CSS, so the browser never sees it. A custom property, like --brand, lives in the browser. Code can change it while the page runs, which is how dark mode can work.

Development🌐 Web Development

Sass

A language for writing CSS with extra tools, like nesting. It turns into plain CSS.

Sass is a language that adds extra tools to CSS, then turns into plain CSS for the browser. It lets you nest rules, share pieces of style, and split your styles into many files. Most people write it in .scss files, where any normal CSS still works. A tool called a compiler turns those files into one .css file. Browsers never see the Sass itself.

Example
Jack has 30 style files for a big shop site. He writes them in Sass, and one build step joins them into one small CSS file.
Why it matters
Big stylesheets stay tidy and short. Many CSS frameworks, like Bootstrap, are written in it.
Full entry
Development🌐 Web Development

CSS Custom Properties

Named values in CSS, like --brand, that you set once and reuse all over the page.

CSS custom properties are values you name once and reuse across a stylesheet. The name starts with two dashes, like --brand. You read it back with var(--brand), and you can give a backup value after a comma. Most people set them on :root, so the whole page can use them. Change one line, and every place that uses it changes too.

Example
Emma's site uses one teal in 40 places. She makes it --brand, so a new brand colour is now a one-line change.
Why it matters
Themes like dark mode become easy. You swap a few values, and the whole page follows.
Full entry

In one line

Sass
A language for writing CSS with extra tools, like nesting. It turns into plain CSS.
CSS Custom Properties
Named values in CSS, like --brand, that you set once and reuse all over the page.