CSS comments start with /* and end with */. They can span several lines. Use them to explain a constraint, a browser workaround or why a value exists, rather than narrating an obvious declaration.

Working example

Explain a layout constraintLink

HTML and CSS

HTML

<article>
  <h2>Project notes</h2>
  <p>
    The comment explains why the maximum width exists. The paragraph remains
    ordinary readable HTML.
  </p>
</article>

CSS

/* Keep the reading column short enough for comfortable line lengths. */
article {
  max-width: 65ch;
  margin-inline: auto;
  padding: 1rem;
}

Edit HTML or CSS to update the preview as you type. Copy code snippet copies the selected tab. Preview spacing and font defaults are not included.

Syntax to avoid

// is not a browser CSS comment. Sass supports silent // comments as part of its own syntax, but that source must be compiled before the browser can use it. Do not copy Sass-only syntax into a <style> element.

CSS comments cannot nest. A */ closes the current comment even when it appears inside text you intended to comment out. An unclosed comment can consume the rest of the stylesheet and make later rules disappear.

Comments are public

A comment is not rendered as page text, but it is still visible in downloaded source. Do not store secrets or private notes there. Keep comments near the rule they explain, and update or remove them when the constraint changes. Compare HTML comments for markup syntax.

Sources

Reference 1 Reference 2 provide the technical details and current compatibility information.