Is a Single-Line CSS Comment Without Any Spaces Between the Opening and Closing Symbols Okay?

CSS comments are identified by the opening symbol of /* and closing symbol of */ and no other symbol. Also, like all other languages supporting this format, the comments may not be nested ("Comments", 2016).

Issue and Research

But what about the spacing in between the opening and closing symbols? Authoritative sources (Robbins, 2012) and experts on StackOverflow ("Is it bad practice to comment out single lines of CSS with //?", 2013) teach leaving one blank space after the opening and before the closing symbol for a single line comment. That looks more readable than skipping the mentioned spaces. The cost for this is two more key presses and the mental effort required. This effort will be repeated for very (manually typed) comment.

Conventions and preferences apart, I wanted to know if this leaving of spaces is mandatory. I checked the various options in a test document in the browser (space after opening only, space before closing only, no spaces at either end) and the comment worked fine i.e. the rule was not applied. That clears that the spaces are not mandatory.

Next, I wanted documented proof. Thus, at the W3C Standards for CSS, the diagram for a comment mentions the inside of a comment to be "anything but * followed by /" ("CSS Syntax Module Level 3", 2014), which allows for the option of skipping the spaces or putting as many spaces as we like after the opening symbol and before the closing symbol.


This appears to be a convention, The standards allow for anything inside a CSS comment except the closing symbol (as the comments cannot be nested).


Comments. (2016). Mozilla Developer Network. Retrieved 29 January 2017, from

CSS Syntax Module Level 3. (2014). Retrieved 29 January 2017, from

Is it bad practice to comment out single lines of CSS with //?. (2013). Retrieved 29 January 2017, from 
Robbins, J. (2012). "Learning Web Design: A Beginner's Guide to HTML, CSS, JavaScript, and Web Graphics" (4th ed.). O'Reilly Media.