Skip to content

What Is Sass? — CSS Preprocessor Overview

DodaTech Updated 2026-06-28 4 min read

In this tutorial, you will learn about What Is Sass?. We cover key concepts, practical examples, and best practices to help you master this topic.

Sass (Syntactically Awesome Style Sheets) is a Css Preprocessor that adds programming features like variables, nesting, mixins, and functions to CSS for writing more maintainable code.

What You'll Learn

You will learn what a CSS preprocessor is, how Sass extends CSS with programming features, the difference between Sass and SCSS syntax, and why Sass is an industry standard.

Why It Matters

CSS alone lacks programming constructs. DodaTech uses Sass to manage consistent theming across Doda Browser, DodaZIP, and Durga Antivirus Pro using shared variables and mixins.

Real-World Use

Durga Antivirus Pro's stylesheet uses Sass variables for brand colors, mixins for responsive breakpoints, and partials to organize over 50 component files into a manageable structure.

flowchart LR
    A[CSS Fundamentals] --> B[What Is Sass]
    B --> C[Installation]
    B --> D[SCSS vs Sass]
    B --> E[Features]
    C --> F[Sass Project]
    style B fill:#c69,stroke:#c69,color:#fff
    style A fill:#e5e7eb,stroke:#9ca3af,color:#374151
    style F fill:#22c55e,stroke:#16a34a,color:#fff

What Is a CSS Preprocessor?

A CSS preprocessor is a tool that extends CSS with features not available in pure CSS. You write code in the preprocessor's language, and it compiles into standard CSS that browsers understand.

Think of it like a Factory. You put in raw materials (Sass code with variables, nesting, logic) and get finished products (clean CSS files) on the other end. The factory handles all the repetitive work.

Why Developers Use Sass

Without Sass, CSS can become repetitive. Consider managing a brand color:

/* Without Sass — repeat the value everywhere */
.header { background-color: #7c3aed; }
.button { background-color: #7c3aed; }
.footer { border-color: #7c3aed; }

With Sass:

$brand: #7c3aed;

.header { background-color: $brand; }
.button { background-color: $brand; }
.footer { border-color: $brand; }

Expected output: Same CSS output, but changing the color requires editing one variable instead of three values.

Key Features Overview

// Variables
$primary: #7c3aed;
$spacing: 1rem;

// Nesting
.card {
  padding: $spacing;
  border: 1px solid $primary;

  .card-title {
    font-size: 1.25rem;
    color: $primary;
  }

  &:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  }
}

// Mixins
@mixin respond-to($size) {
  @media (min-width: $size) {
    @content;
  }
}

.sidebar {
  width: 100%;

  @include respond-to(768px) {
    width: 250px;
  }
}

Expected output: Compiled CSS with expanded selectors from nesting, the variable values inserted, and media query mixins resolved.

The Two Syntaxes

Sass has two syntaxes:

  • SCSS (.scss) — Uses curly braces and semicolons, like CSS. Most popular.
  • Sass (.sass) — Uses indentation, no braces or semicolons. Older syntax.
// SCSS syntax
$color: red;
.button {
  color: $color;
  &:hover { color: darken($color, 10%); }
}
// Sass (indented) syntax
$color: red
.button
  color: $color
  &:hover
    color: darken($color, 10%)

Expected output: Both produce identical CSS. SCSS is more popular and easier for CSS developers to learn.

Common Mistakes

1. Thinking Sass Replaces CSS

Sass compiles to CSS. You still need to understand CSS fundamentals. Sass is a tool on top of CSS, not a replacement.

2. Over-Nesting Selectors

Nesting too deep (4+ levels) creates overly specific CSS selectors that are hard to override.

3. Using Sass for Everything

Some features like CSS custom properties (variables) are better handled with native CSS. Use Sass for compile-time logic and CSS variables for runtime theming.

4. Ignoring Compiled Output

Always check the compiled CSS output. If the output is bloated or unexpected, adjust your Sass patterns.

5. Not Using Partials

Putting all Sass in one file defeats the modularity benefit. Use partials to organize code into logical files.

Practice Questions

  1. What does "Sass" stand for? Syntactically Awesome Style Sheets.

  2. What is the difference between Sass and SCSS? Sass uses indentation-based syntax (.sass). SCSS uses curly braces and semicolons (.scss) like CSS.

  3. Name three features Sass adds to CSS. Variables, nesting, mixins, functions, partials, inheritance (any three).

  4. What compiles Sass code to browser-readable CSS? The Sass compiler (Dart Sass) converts .scss/.sass files into .css files.

  5. Is SCSS backward compatible with CSS? Yes. Any valid CSS is also valid SCSS.

Challenge

Write a small SCSS stylesheet that defines three color variables, uses them in selectors, includes one level of nesting, and compiles to CSS. Show both the SCSS source and the compiled output.

FAQ

Is Sass still relevant with modern CSS?

Yes. While CSS now has custom properties and nesting, Sass still offers mixins, functions, control directives, and the 7-1 architecture pattern that CSS lacks.

Do I need a build tool to use Sass?

Yes. Sass requires a compiler. You can use the CLI (npx sass), build tools like Vite or Webpack, or GUI applications.

What is Dart Sass?

Dart Sass is the primary implementation of Sass. It replaced Node Sass (which used LibSass) as the reference implementation.

Can I use Sass with Bootstrap?

Yes. Bootstrap's source is written in Sass. You can customize Bootstrap by overriding its Sass variables.

Is Sass difficult to learn?

No. If you know CSS, you already understand most of Sass. The new concepts are variables, nesting, and mixins, which you can learn in an afternoon.

Mini Project

Convert a small CSS file (50+ lines) into SCSS by extracting repeated values into variables, nesting related selectors, and organizing the file into sections with comments.

What's Next

Now Install Sass on your system. Then learn the difference between SCSS vs Sass syntax.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro