Single-line comments


#1

I’m sure this has been discussed many times before, but is there any reason why this cannot be supported?


#2

Of course its supported:

body {
  /*My Comment*/
}

That’s one line.

Now I’m sure what your talking about is double backslashes // My comment

Well each language has its own way, just like in HTML its <!-- -->


#3

Yes, sorry, I meant with the double-slash syntax (as used in C++, C#, PHP, JavaScript, etc.)


#4

For one thing, it would break stylesheet.replace(/\n/g,'').replace(/\s/g,' ') as a minification strategy. (In other words, it doesn’t play nice with inline styles.)


#5

Minifiers can simply replace single-line comments with multi-line comments before removing line ending characters.


#6

Main complaint about single-line comments in CSS is typically that double slash in nonquoted absolute URLs would be incorrectly treated as beginning of a comment.

This could probably be solved by allowing each single-line comment to be the only contents of its line (with guaranteedly nothing before the comment), but some CSSWG people who like the word “confusing” would probably call this confusing.