Sass Syntax

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
.scss & .sass

What You’ll Learn

Sass supports two syntaxes. This page compares SCSS and the indented syntax, shows how the same styles compile either way, and walks through five beginner examples.

01

SCSS

.scss

02

Indented

.sass

03

Same power

Equal features

04

Interoperable

Load each other

05

Choose

Team preference

06

Practice

5 examples

What Is Sass Syntax?

Official docs: Sass ships two ways to write the same language. Your team picks one (or mixes them). The compiler still outputs plain CSS either way.

  • SCSS — file extension .scss; braces and semicolons like CSS.
  • Indented syntax — file extension .sass; indentation replaces braces/semicolons.
  • Feature set is the same: variables, nesting, mixins, modules, and more.
  • Each syntax can load the other (for example with @use).
💡
Beginner tip

Start with SCSS. You can paste most CSS into a .scss file and keep learning Sass features gradually. The rest of CodeToFun’s Sass tutorials use SCSS.

📄 The SCSS Syntax

SCSS is a superset of CSS (with a few small exceptions). Essentially all valid CSS is valid SCSS. That similarity makes it the easiest syntax to learn and the most popular.

styles.scss
@mixin button-base() {
  display: inline-flex;
  position: relative;
  border: none;
  vertical-align: middle;

  &:hover {
    cursor: pointer;
  }

  &:disabled {
    cursor: default;
    pointer-events: none;
  }
}

📄 The Indented Syntax (.sass)

This was Sass’s original syntax, so it uses the .sass extension and is sometimes just called “Sass.” It supports the same features as SCSS, but:

  • Wherever CSS/SCSS would use curly braces, indent one level deeper.
  • Wherever a statement can end at the end of a line, that counts as a semicolon.
  • A few extra indented-only rules appear throughout the official reference.
styles.sass
@mixin button-base()
  display: inline-flex
  position: relative
  border: none
  vertical-align: middle

  &:hover
    cursor: pointer

  &:disabled
    cursor: default
    pointer-events: none

⚖️ SCSS vs Indented Syntax

TopicSCSS (.scss)Indented (.sass)
Looks likeCSS with braces { }Python-like indentation
Statement endSemicolon ;End of line (usually)
Learning curveEasiest if you know CSSLess typing, stricter layout
PopularityMost common todayStill fully supported
FeaturesFull Sass feature setSame feature set

📈 Multiline Statements (Indented)

Official docs (Dart Sass 1.84.0+): in the indented syntax, a statement may span multiple lines when the break happens where the statement cannot end—inside parentheses or brackets, or between keywords in a Sass-specific @-rule.

LibSass and Ruby Sass do not support this. Many projects still run older Dart Sass (for example 1.69.x), where that multiline style will fail to compile. Prefer keeping indented statements on fewer lines, or use SCSS for long values, until your toolchain is on 1.84+.

⚡ Quick Reference

GoalSCSSIndented
File extension.scss.sass
Nest a rule&:hover { … }&:hover then indent
End a declarationcolor: red;color: red
Compilesass styles.scss styles.csssass styles.sass styles.css
Load the other@use "tokens"; works across extensions

Examples Gallery

Side-by-side where it helps. Open View Compiled CSS—both syntaxes produce the same CSS for equivalent source.

📚 Getting Started

Same styles, two spellings—identical CSS output.

Example 1 — Same Button in SCSS and Indented

Variables, nesting, and & work the same; only punctuation differs.

styles.scss
$brand: #036;

.button {
  background: $brand;
  color: #fff;

  &:hover {
    background: #024;
  }
}
styles.sass
$brand: #036

.button
  background: $brand
  color: #fff

  &:hover
    background: #024

How It Works

The compiler does not care which syntax you chose. The CSS file only contains the finished selectors and values.

Example 2 — Mixin in Both Syntaxes

Mixins and @include are available in SCSS and indented form.

styles.scss
@mixin card($radius) {
  border-radius: $radius;
  padding: 1rem;
}

.panel {
  @include card(8px);
  border: 1px solid #ddd;
}
styles.sass
@mixin card($radius)
  border-radius: $radius
  padding: 1rem

.panel
  @include card(8px)
  border: 1px solid #ddd

How It Works

Drop the braces and semicolons in .sass; keep the same mixin API. Output is identical.

📈 Everyday SCSS Patterns

Most tutorials (including this site) write SCSS day to day.

Example 3 — SCSS with Interpolation

Dynamic class names use the same interpolation rules in either syntax.

styles.scss
$theme: dark;

.card-#{$theme} {
  display: grid;
  grid-template-columns: 1fr 2fr;
}

How It Works

Syntax choice does not change how #{ } works—only how you write braces and line endings.

Example 4 — Media Query in Both Syntaxes

At-rules nest under indentation in .sass the same way blocks nest in SCSS.

styles.scss
$bp: 768px;

@media (min-width: $bp) {
  .sidebar {
    width: 240px;
  }
}
styles.sass
$bp: 768px

@media (min-width: $bp)
  .sidebar
    width: 240px

How It Works

Modern Dart Sass accepts $bp in the media condition without #{$bp}. Both syntaxes compile to the same query.

Example 5 — Typical SCSS Token File

A small spacing token file—the style most teams ship in .scss.

styles.scss
$space: 1rem;

.box {
  margin: $space;
  // SCSS keeps braces and semicolons
  padding: $space * 2;
}

How It Works

Silent comments and math work the same as in indented files; SCSS just keeps the CSS-like punctuation.

🚀 Real-World Use Cases

  • New projects — default to SCSS for hiring and tooling familiarity.
  • Migrating CSS — rename .css.scss and adopt Sass gradually.
  • Legacy indented codebases — keep .sass or convert file by file.
  • Mixed repos@use a .sass partial from SCSS (or the reverse).
  • Teaching — show both once, then standardize on one team style.

🧠 How Compilation Works

1

Pick a syntax

Write .scss (braces) or .sass (indentation).

Author
2

Parse by extension

Dart Sass chooses the parser from .scss vs .sass.

Parse
3

Shared features

Variables, nesting, mixins, modules resolve the same way.

Evaluate
4

CSS out

Browsers only ever see standard CSS.

⚠️ Common Pitfalls

  • Wrong extension — SCSS in a .sass file (or the reverse) fails to parse.
  • Mixing braces into .sass — indented files do not use { } / ; the SCSS way.
  • Thinking features differ — syntax is style; capabilities match.
  • Multiline indented on old Dart Sass — needs 1.84+; older versions error.
  • Inconsistent team style — pick one primary syntax for new files.

💡 Best Practices

✅ Do

  • Prefer SCSS for new learning and most teams
  • Match the file extension to the syntax you write
  • Document the team standard in the repo README
  • Reuse existing .sass files via @use instead of rewriting overnight
  • Keep indentation consistent (spaces) in indented files

❌ Don’t

  • Paste SCSS braces into a .sass file
  • Assume “Sass” always means the indented syntax
  • Force a full rewrite when interoperability already works
  • Rely on multiline indented statements before upgrading Dart Sass
  • Mix tab styles carelessly in indented projects

Key Takeaways

Knowledge Unlocked

Five things to remember about Sass syntax

Two spellings, one language, one CSS output.

5
Core concepts
📝 02

.sass

indented original

Classic
⚙️ 03

Same features

not two languages

Power
🔁 04

Interoperable

load each other

Modules
05

Pick one

team consistency

Style

❓ Frequently Asked Questions

Two. SCSS uses the .scss extension and looks like CSS with braces and semicolons. The indented syntax uses .sass and uses indentation instead of braces and semicolons.
SCSS. Official docs call it the easiest to learn and the most popular because almost all valid CSS is valid SCSS.
No. Both support the same Sass features. Only the writing style differs (braces/semicolons vs indentation).
Yes. Official docs: each syntax can load the other (for example with @use), so teams can mix .scss and .sass files if needed.
Because it uses the .sass extension, people often just call it "Sass". SCSS is still Sass—it is the CSS-compatible syntax of the same language.
In Dart Sass 1.84+, yes—when line breaks occur where a statement cannot end (inside parentheses/brackets, or between keywords in Sass @-rules). Older compilers (including many 1.69.x installs) do not support that yet.
Did you know?

The name “SCSS” stands for Sassy CSS. It was added so developers could keep writing CSS-looking code while still using every Sass feature the indented syntax already had.

Conclusion

Sass offers SCSS for CSS-like writing and an indented .sass syntax for brace-free files. Features match; output is CSS either way—pick a team standard and stick with it.

Continue with Sass Parsing or Sass Variables.

Next: Sass Parsing

Learn UTF-8 encoding and how Sass fails fast on invalid syntax.

Sass Parsing →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful