Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why do /**/ comments work in stylesheets but // comments don't?

Tags:

comments

css

Is there a good reason for this? Lame question, but I just wondered if there was a reason why.

like image 851
leeand00 Avatar asked Mar 19 '10 17:03

leeand00


People also ask

How do you comment in a stylesheet?

To comment in CSS, simply place your plain text inside /* */ marks. This tells the browser that they are notes and should not be rendered on the front end.

How do you insert a comment in CSS stylesheet?

The /* */ comment syntax is used for both single and multiline comments. There is no other way to specify comments in external style sheets. However, when using the <style> element, you may use <!

How do you comment out a shortcut in CSS?

CSS allows only multi-line comments. In Aptana 3 just select a region you would like to comment out and use ctrl + shift + / .

Can HTML comments be used in CSS?

The stuff inside the /* */ marks are CSS comments. This allows you to enter notes into CSS that will not be interpreted.


1 Answers

Because the specification allows for /**/ but not // :)

Seriously, though, CSS treats newlines like all other whitespace, and would not be able to determine the end of the comment without a terminating delimiter.

like image 170
jball Avatar answered Oct 22 '22 11:10

jball