Sass Comments

Beginner
10 min read
Updated: Nov 2026
5 examples
Compiled CSS

Definition and Usage

Sass supports two comment styles. Silent comments start with // and never appear in CSS. Loud comments use /* */ and (usually) compile to CSS comments.

Start a loud comment with /*! to keep it even in compressed mode — useful for licenses. Loud comments can use interpolation (#{…}). Document libraries with triple-slash /// SassDoc comments.

Official terms.

Sass docs call // silent and /* */ loud. Silent comments may as well not exist to the compiler.

Compressed mode.

Regular loud comments are stripped when you compile with --style=compressed. /*! comments always ship.

Indented syntax differs.

In .sass, everything indented under // or /* is part of the comment, and closing */ is optional for loud blocks.

Syntax

SCSS
// Silent — never in CSS

/* Loud — in CSS (except compressed) */

/* Interpolation: #{1 + 1} */

/*! Keep me even when compressed */

p /* anywhere whitespace is allowed */ .sans {
  font: Helvetica, // trailing silent ok
        sans-serif;
}

Pattern: author notes with // → ship labels / licenses with /* */ or /*! */ → document APIs with ///.

Comment Types

Pick the right comment for the job:

FormIn CSS?Best for
// …NeverAuthor notes, TODOs, explaining Sass logic
/* … */Yes (stripped if compressed)Section labels that help when reading CSS
/*! … */AlwaysLicenses, copyright, version banners
/* … #{$x} */Yes (after eval)Dynamic banners with variables / math
/// …NeverSassDoc docs above mixins / functions / vars

SCSS Examples

Each example shows a core comment behavior. Open View Compiled CSS for verified output (expanded unless noted).

Example 1 — Official SCSS Comment Mix

Silent lines disappear; loud and important comments remain in expanded CSS.

SCSS
// This comment won't be included in the CSS.

/* But this comment will, except in compressed mode. */

/* It can also contain interpolation:
 * 1 + 1 = #{1 + 1} */

/*! This comment will be included even in compressed mode. */

p /* Multi-line comments can be written anywhere
  * whitespace is allowed. */ .sans {
  font: Helvetica, // So can single-line comments.
        sans-serif;
}

How It Works

  1. Silent // notes vanish completely.
  2. Loud comments stay in expanded CSS.
  3. #{1 + 1} evaluates to 2 inside the comment.
  4. Inline comments act as whitespace — p .sans compiles cleanly.

Example 2 — Everyday Silent & Loud Notes

Use silent comments for authors; loud comments when the CSS file should keep a label.

SCSS
$brand: #036;

// Section: buttons
.button {
  /* Primary action */
  background: $brand;
  color: #fff; // keep text readable
}

/*! Copyright CodeToFun - keep in production CSS */
.footer {
  font-size: 0.875rem;
}

How It Works

  1. Section // and trailing silent notes are gone.
  2. Loud property comment remains on background.
  3. /*! copyright stays for production CSS.
  4. $brand still resolves to #036.

Example 3 — Interpolation Inside Loud Comments

Evaluate variables and math before the comment is written to CSS.

SCSS
$version: "1.2.0";
$year: 2026;

/*! Theme kit v#{$version} - #{$year} */
.card {
  // silent note: padding tokens
  padding: 1rem;
  /* Loud: border uses brand */
  border: 1px solid #c6538c;
}

How It Works

  1. #{$version} and #{$year} become concrete text.
  2. Important banner keeps the resolved version string.
  3. Silent padding note never ships.
  4. Regular loud label remains in expanded CSS.

Example 4 — Compressed Output Keeps /*! Only

Regular loud comments disappear in compressed mode; important ones stay.

SCSS
.nav {
  display: flex;
  gap: 1rem; /* inline loud */
  // gap uses rem for accessibility
  align-items: center;
}

/*! License: keep me */

How It Works

  1. --style=compressed minifies the stylesheet.
  2. Inline loud comment is stripped.
  3. Silent // was never in CSS.
  4. /*! License */ survives beside the minified rules.

Example 5 — SassDoc-Style /// Above a Function

Triple-slash comments document APIs; they stay silent in the CSS.

SCSS
/// Computes an exponent for design scales.
/// Prefer math.pow when available; this is a teaching stub.
@function pow($base, $exponent) {
  $result: 1;
  @for $_ from 1 through $exponent {
    $result: $result * $base;
  }
  @return $result;
}

.scale {
  font-size: pow(2, 3) * 1px;
}

How It Works

  1. /// blocks are silent — no CSS comment output.
  2. SassDoc (or a human) can read the Markdown above the API.
  3. pow(2, 3) evaluates to 8.
  4. Only the computed 8px font size ships.

Edge Cases & Pitfalls

Most comment surprises are compressed stripping, wrong silence, or indented-block comments.

minify

Loud comments vanish when compressed

If a license must ship, use /*!. Plain /* */ will not survive --style=compressed.

silent

Do not expect // in CSS

Browsers never see silent comments. Put production-facing notes in loud or important comments.

sass

Indented syntax comments whole blocks

Everything indented under // is commented out. Easy to accidentally disable nested rules.

docs

/// is for tools, not CSS

SassDoc comments never appear in output. Use them above public mixins, functions, and variables.

Sass Support

Comments are core language syntax in both SCSS and the indented syntax. Behavior is consistent on Dart Sass.

ImplementationStatus
Dart SassSupported (recommended)
LibSass / node-sassSupported (deprecated toolchain)
Ruby SassSupported historically (end-of-life)
BrowsersOnly see loud / /*! comments that survive compile

Prefer Dart Sass. Control comment stripping with --style=compressed.

Key Takeaways

  • Silent //: author-only — never in CSS.
  • Loud /* */: ships in expanded CSS; stripped when compressed.
  • /*!: always kept — licenses and version banners.
  • ///: SassDoc docs for public mixins and functions.

One line: use // for you, /* */ for CSS readers, and /*! when the note must survive minify.

Compile Notes

Conceptual flow for comments:

flow.txt
1. Parse // (silent) and /* */ (loud / important)
2. Evaluate #{…} inside loud comments
3. Drop all silent and /// documentation comments
4. Emit loud comments into CSS (unless compressed)
5. Always keep /*! comments in the final CSS

Frequently Asked Questions

Silent comments start with // and go to the end of the line. They are never emitted as CSS. In the indented .sass syntax, everything indented under // is also commented out.
Loud comments use /* */. When written where a statement is allowed, they compile to CSS comments. By default they are removed in compressed output.
A multi-line comment that begins with /*! is kept even in compressed mode. Use it for licenses, copyright notices, and other text that must ship in the CSS file.
Yes for loud /* */ comments. Expressions inside #{ } are evaluated before the comment is compiled. Silent // comments are not emitted, so interpolation there does not appear in output.
Documentation comments use three slashes (///) above mixins, functions, variables, or placeholders. SassDoc reads them as Markdown and can generate library docs.
The idea is the same, but indented syntax is indentation-based: blocks under // or /* are included in the comment, and */ is optional for loud comments. Inline expression comments match SCSS.

Next: Sass Interpolation

Inject values into selectors, property names, strings, and loud comments.

Sass Interpolation →

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.

8 people found this page helpful