CSS Comment

August 7, 2017
/* Commenting in CSS */

The one and only way to comment in CSS is using /* comment here */.

/* 
  Multiline Comment:
   - add more css later
*/
.content {
  line-height: 1em; /* comment again */
}

No single line comment

Single line comment like // please don't comment like this is not recommended. Though it won’t break CSS in some cases, but you will bump into issues when the CSS is minified.

.content {
  line-height: 1em; // please don't comment like this
}

No nested comment

One of the limitation with CSS comment is you can’t do nested comment.

/* nested comment won't work
.content {
  line-height: 1em; /* nested comment */
}
 */

Less and Sass

You might consider Less and Sass if you want to support single line comment and nested comment.

This work is licensed under a
Creative Commons Attribution-NonCommercial 4.0 International License.