Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

"What’s your opinion on pre-processors like SASS and LESS? Does CSS have anything to learn from them?

(...) My own favorites would be nested comments, and single-line comments (starting with //). When CSS turns 50 I’ll tell you why they were not part of CSS from the beginning."

Now, this makes me really wonder why single-line comments weren't part of the spec from the beginning. And I can't wait 30 years... Anyone an idea?



single-line comments are already supported in the way that are invalid css :) so if you comment with // the stuff that follow will be ignored. Again, it is invalid CSS and I am not suggesting that you should use it, just bringing that up :)

I personally like how single-comments works on pre-processors. They are ignored at compile time and therefore are a good way to comment on functions, mixins or anything that won't be compiled to raw CSS.


Be careful with using // in CSS. It causes some browsers to completely ignore the whole rest of the CSS file after the line you wanted to comment out (iirc IE9 does this).

When I want to quickly comment something out (and don't have an editor shortcut handy), I just put an 'x' in front of the property name. I.e.:

    xbackground-color: #f0f;


Yeah, well anything invalid :)


/* single-line comment */




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: