TExcelTAD
Home › Sass › Sass Intro

Sass Introduction

Sass (Syntactically Awesome Style Sheets) is a language that compiles to CSS. You write styles with extra features — variables, nesting, reusable mixins, functions, loops and modules — and the Sass compiler turns them into the plain CSS that browsers understand.

Browsers never see Sass. It is a build-time tool: your .scss files go in, a .css file comes out.

styles.scss  ──►  Sass compiler  ──►  styles.css  ──►  browser

Why use Sass?

Plain CSS has improved a lot (it now has custom properties, nesting and calc()), but large stylesheets still get repetitive. Sass helps you:

Problem in plain CSS Sass feature that solves it
The same colour copied into 40 rules Variables ($brand: #cc6699;)
Long, repeated selector prefixes Nesting
Copy-pasted groups of declarations Mixins (@mixin / @include)
One giant file Partials and the module system (@use)
Generating many similar classes by hand Loops (@each, @for)
Computing sizes and colour shades Functions and built-in modules (sass:math, sass:color)

Two syntaxes: SCSS and indented

Sass has two syntaxes. SCSS (.scss) is a superset of CSS: every valid CSS file is also valid SCSS, and it uses braces and semicolons. The older indented syntax (.sass) uses indentation instead of braces. This course uses SCSS, which is what almost every project uses today.

sass
// Indented syntax (.sass) – shown for recognition only
$brand: #cc6699
.button
  color: $brand

Your first Sass program

Press ▶ Run to compile the SCSS. The output panel shows the CSS the compiler produces. Below it, a preview renders some HTML using that CSS.

scss · try it yourself
$brand: #cc6699;
$radius: 8px;

.button {
  background: $brand;
  color: white;
  padding: 10px 18px;
  border-radius: $radius;
  border: none;

  &:hover {
    opacity: 0.85;
  }
}
.button {
  background: #cc6699;
  color: white;
  padding: 10px 18px;
  border-radius: 8px;
  border: none;
}
.button:hover {
  opacity: 0.85;
}

Notice two things in the output:

  1. $brand and $radius are gone — their values were substituted. Sass variables exist only at compile time.
  2. The nested &:hover block became a separate .button:hover rule.

Tip: Every playground in this course is editable. Change $brand to teal and press Ctrl+Enter to recompile.

Sass is a superset of CSS

Because SCSS accepts any CSS, you can rename styles.css to styles.scss and start adding Sass features gradually. Plain CSS passes straight through:

scss · try it yourself
h1 {
  font-family: system-ui, sans-serif;
  color: #333;
}

.note {
  border-left: 4px solid #cc6699;
  padding: 8px 12px;
}
h1 {
  font-family: system-ui, sans-serif;
  color: #333;
}

.note {
  border-left: 4px solid #cc6699;
  padding: 8px 12px;
}

Which Sass?

There have been several implementations over the years. Dart Sass is the official, actively developed one; the old Ruby Sass and LibSass (node-sass) are deprecated. This course targets modern Dart Sass (1.9x and later) and its module system (@use, @forward, sass:math, sass:color …). Older tutorials that use @import, darken() or / for division show patterns that now produce deprecation warnings — you will learn the modern replacements.

Test yourself

What does the browser receive when you use Sass?

  1. The .scss file
  2. Plain compiled CSS
  3. A JavaScript bundle that interprets Sass
  4. Both the .scss and the .css file

Which statement about SCSS syntax is true?

  1. It uses indentation instead of braces
  2. Every valid CSS file is also valid SCSS
  3. It cannot contain plain CSS rules
  4. It must be written in .sass files

Which Sass implementation is the official, maintained one?

  1. Ruby Sass
  2. LibSass (node-sass)
  3. Dart Sass
  4. PostCSS