Skip to content

Common Sass Mistakes

This lesson consolidates the most frequent Sass mistakes covered throughout this course into one focused reference, along with why each one happens and how to fix or avoid it.

Why These Mistakes Keep Happening

Most recurring Sass mistakes come from a small set of root causes: outdated habits carried over from @import-era code, assumptions borrowed from other languages (like JavaScript's truthiness rules), and simply not checking the actual compiled CSS output.

// Mistake: dividing with /
$width: 100% / 3;

// Fix: use math.div()
@use 'sass:math';
$width: math.div(100%, 3);

This single fix, reaching for math.div(), resolves one of the most common deprecation warnings developers encounter in modern Dart Sass.

Categories of Common Mistakes

Module system mistakes
Truthy/falsy assumption mistakes
Nesting and specificity mistakes
Control rule and loop mistakes
Performance and output-size mistakes
  • Module mistakes usually involve leftover @import habits or missing namespace prefixes.
  • Truthy/falsy mistakes usually involve assuming 0 or "" are falsy, as in JavaScript.
  • Nesting mistakes usually involve overly deep selectors or misplaced & spacing.
  • Loop mistakes usually involve off-by-one errors with through vs to, or unchecked output size.

Common Sass Mistakes Cheatsheet

Frequent mistakes and their direct fix.

Mistake Fix
Using @import in new code Use @use/@forward instead
Dividing with / Use math.div()
Assuming 0 is falsy Only false and null are falsy in Sass
& .child instead of &.child Check for the unintended space carefully
Confusing through and to through is inclusive, to is exclusive
Installing node-sass Install sass (Dart Sass) instead
Forgetting !default Add it to every configurable variable in a shared partial

Module System Mistakes

The most common module mistake is simply continuing old @import habits in new code. A close second is forgetting the namespace prefix (colors.$primary) after switching to @use.

Logic and Control Rule Mistakes

Assuming Sass truthiness matches JavaScript's, and mixing up through/to in @for loops, are two of the most frequent logic-related mistakes, both stemming from applying assumptions from other languages without checking Sass's actual documented behavior.

Common Mistakes

  • Never reading the actual compiled CSS output, catching mistakes only after they reach production.
  • Ignoring Dart Sass deprecation warnings instead of addressing them as they appear.
  • Copy-pasting old Sass patterns from outdated tutorials or Stack Overflow answers without checking their current recommended status.
  • Not keeping the Sass compiler itself up to date, missing newer, safer built-in functions and clearer error messages.

Key Takeaways

  • Most recurring Sass mistakes trace back to outdated @import-era habits or assumptions borrowed from other languages.
  • Truthy/falsy behavior and through/to range inclusivity are two of the most common logic mistakes.
  • Many mistakes are only visible in the compiled CSS output, not in the SCSS source itself.
  • Address compiler deprecation warnings promptly rather than ignoring them.

Pro Tip

Treat every Dart Sass deprecation warning as a same-week fix rather than deferred technical debt, they're deliberately introduced well before a breaking change ships, and fixing them early is far cheaper than a large migration later.