Is a Single-Line CSS Comment Without Any Spaces Between the Opening and Closing Symbols Okay?
Issue and ResearchBut 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.
ConclusionThis appears to be a convention, The standards allow for anything inside a CSS comment except the closing symbol (as the comments cannot be nested).
ReferencesComments. (2016). Mozilla Developer Network. Retrieved 29 January 2017, from https://developer.mozilla.org/en-US/docs/Web/CSS/Comments#Notes
CSS Syntax Module Level 3. (2014). W3.org. Retrieved 29 January 2017, from https://www.w3.org/TR/css-syntax-3/#comment-diagram
Is it bad practice to comment out single lines of CSS with //?. (2013). Stackoverflow.com. Retrieved 29 January 2017, from http://stackoverflow.com/a/20192639/216084