A partial archive of discourse.wicg.io as of Saturday February 24, 2024.

Single-line comments

glen84
2015-08-08

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

Edwin_Reynoso
2015-08-08

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 <!-- -->

glen84
2015-08-08

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

stuartpb
2015-08-08

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.)

glen84
2015-08-08

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

MT
2015-08-08

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.