w3c / csswg-drafts

CSS Working Group Editor Drafts
https://drafts.csswg.org/
Other
4.45k stars 657 forks source link

[Feature request] Support for single line comments #7115

Open LifeIsStrange opened 2 years ago

LifeIsStrange commented 2 years ago

Doing / / is NOT ergonomic especially for quick prototyping, // comments are an affordance that is provided by most languages out there, including Javascript. It's 2022 and I think this is a relatively high impact ergonomy wise, low complexity feature and therefore a low hanging fruit regarding developper experience. Sure there might or not be some syntax edge cases, but I'm sure requiring e.g to be a space or a newline before the // would filter such exceptions (background-url) and/or by requiring to be a space after the // There are many other possible resolution strategies. One could look at how SCSS does it: https://sass-lang.com/documentation/syntax/comments#in-scss Please, make it happen :)

tabatkins commented 2 years ago

This has been discussed in the past, see https://lists.w3.org/Archives/Public/www-style/2012Aug/0622.html.

Ultimately, we very likely can't do this without extensive compatibility testing, because (a) there's already at least two places in CSS where a // can validly appear (unquoted URLs, and 'border-image'), and (b) anyone using // to comment out properties today (something I also use, which works because it just makes an invalid property) and using a CSS minifier that doesn't remove invalid properties would have the entire rest of their stylesheet commented out.

This is the sort of thing that would have been nice to design into CSS early on, but at this point it's very unlikely to be possible.

LifeIsStrange commented 2 years ago

Well if a viable resolution strategy cannot be found then CSS should introduce single line comments with # # is the second most popular syntax for single line comments and is to me an acceptable plan B. It would differ from an ID selector by e.g. requiring a space after.