Sass Comments

Beginner
⏱️ 12 min read
📚 Updated: Jul 2026
🎯 5 Examples
// and /* */

What You’ll Learn

Sass comments come in silent (//) and loud (/* */) forms. This page covers both syntaxes, /*! important comments, interpolation, SassDoc /// docs, and five compiled examples.

01

Silent

// never in CSS

02

Loud

/* */ to CSS

03

Important

/*! */ kept

04

#{…}

In loud comments

05

SassDoc

/// docs

06

Practice

5 examples

What Are Sass Comments?

Official docs: both SCSS and the indented syntax support two comment styles—comments defined with /* */ that are (usually) compiled to CSS, and comments defined with // that are not.

  • Silent (//) — never appear in the CSS output.
  • Loud (/* */) — usually become CSS comments (removed in compressed mode).
  • Important (/*! */) — loud comments that survive compression.
  • Loud comments may contain interpolation that Sass evaluates first.
💡
Beginner tip

Prefer // for everyday notes about why a rule exists. Reach for /* */ only when someone reading the compiled CSS needs the note, and /*! */ for licenses that must stay after minification.

📝 Syntax (SCSS)

In SCSS, comments work like JavaScript: // runs to the end of the line; /**/ can span multiple lines. Both kinds can appear almost anywhere whitespace is allowed.

styles.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;
}

⚖️ Silent vs Loud Comments

Feature// silent/* */ loud
In CSS output?NeverYes (expanded / nested styles)
Compressed modeStill absentStripped (unless /*!)
InterpolationNot useful in outputEvaluated into the CSS comment
Best forAuthor notes, TODOsNotes for CSS readers, section banners

⚡ Important Comments (/*!)

By default, multi-line comments are stripped from compressed CSS. If a comment begins with /*!, Sass keeps it in every output style—handy for copyright and license headers that must remain after minification.

📄 Comments in the Indented Syntax

Official docs: in .sass (indented) files, comments are indentation-based. Silent // comments never emit CSS, and everything indented beneath the opening // is also commented out. Loud /* comments work the same way with indentation; the closing */ is optional. Both still support interpolation and /*!. Inside expressions, comment syntax matches SCSS.

💡
Most tutorials use SCSS

The examples on this page use .scss. If you write indented Sass, remember that nested lines under // or /* are part of the comment block.

📚 Documentation Comments (SassDoc)

When you ship a style library, document mixins, functions, variables, and placeholders with silent /// comments directly above the item. Tools such as SassDoc parse the text as Markdown and support annotations like @param and @return.

These are still silent comments—they never appear in CSS. They exist for humans and documentation generators.

⚡ Quick Reference

GoalCode
Silent note// why this rule exists
Loud CSS comment/* Section: buttons */
Keep after minify/*! License text */
Interpolate in loud/* v#{$version} */
Document an API/// @param {Color} $brand
Inline silentcolor: $brand; // brand token

Examples Gallery

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

📚 Getting Started

Official-style mix of silent, loud, important, and inline comments.

Example 1 — Official SCSS Comment Mix

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

styles.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

The silent // notes vanish. Loud comments stay (with #{1 + 1} evaluated to 2). The selector comment is whitespace, so 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.

styles.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

Section and trailing // notes are gone. The loud property comment and the /*! copyright line remain in the CSS.

📈 Interpolation, Compression & Docs

Build version banners, survive minify, and document APIs.

Example 3 — Interpolation Inside Loud Comments

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

styles.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

#{$version} and #{$year} become concrete text in the important banner. The silent padding note never ships.

Example 4 — Compressed Output Keeps /*! Only

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

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

/*! License: keep me */

How It Works

With --style=compressed, the inline /* inline loud */ is removed. Only /*! License: keep me */ survives beside the minified rules.

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

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

styles.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

SassDoc (or a human) can read the /// block. The compiler ignores it for CSS output and only emits the computed 8px font size.

🚀 Real-World Use Cases

  • Author notes — explain non-obvious selectors with //.
  • Section banners — loud /* === Buttons === */ in readable CSS builds.
  • Licenses/*! so minifiers keep the legal header.
  • Build metadata — interpolate version/date into an important banner.
  • Library docs/// + SassDoc for public mixins and functions.

🧠 How Compilation Works

1

Parse comments

Classify // vs /* */ vs /*! and any indentation blocks.

Read
2

Evaluate loud #{ }

Interpolate expressions inside multi-line comments.

Expand
3

Apply output style

Drop silent always; drop normal loud in compressed mode.

Filter
4

CSS ships

Only surviving loud / important comments remain.

⚠️ Common Pitfalls

  • Expecting // in CSS — silent comments never compile out.
  • Assuming loud comments survive minify — use /*! for that.
  • Putting secrets in loud comments — they may ship to every visitor.
  • Forgetting indented blocks — in .sass, nested lines under // are also comments.
  • Mixing SassDoc with loud comments — use /// above APIs, not /* */.

💡 Best Practices

✅ Do

  • Default to // for everyday author notes
  • Use /*! for licenses and required banners
  • Document public mixins/functions with ///
  • Explain why, not what the CSS already shows
  • Keep comments short and close to the code they describe

❌ Don’t

  • Leave outdated loud comments that confuse CSS readers
  • Rely on normal /* */ in production minified CSS
  • Comment out large dead blocks forever—delete or use version control
  • Put credentials or private URLs in any loud comment
  • Skip documenting library APIs your teammates consume

Key Takeaways

Knowledge Unlocked

Five things to remember about Sass comments

Silent, loud, important, interpolation, and SassDoc.

5
Core concepts
📝 02

/* loud */

usually in CSS

Output
03

/*! keep */

survives minify

Prod
🔢 04

#{ }

in loud comments

Power
📚 05

/// docs

SassDoc ready

Libs

❓ 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 written to CSS. 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.
Did you know?

Loud comments are sometimes called that by contrast with silent comments—the official Sass docs use both nicknames so beginners can remember which ones “speak” in the CSS file.

Conclusion

Sass gives you silent // notes for authors, loud /* */ comments for CSS readers, and /*! when a banner must survive compression. Add /// when you document a library API.

Continue with Sass Interpolation or Sass Variables.

Next: Sass Interpolation

Learn how #{ } injects SassScript into selectors, names, and paths.

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.

5 people found this page helpful