Css comments

I know that to comment out css you use /* code code code /
but i noticed that sometime you find a php // and it seems to nulify the css code as well. at least for that one line.
would there be issues if the coder uses // instead that the /
*/ ?
it seems it stills works.
thx
D

Hi,

CSS comments are as you stated /* stuff here ignored as far as css is concerned */. They are the only comments you should use.

What I think you are experiencing is something like this:


//
div{background:red}

The rule above will not work because CSS is looking for a selector called “// div {}” and none exists. All you have done is describe a non existent element so nothing gets matched. The rule following that would match though.

It’s the same problem you get when someone duplicates a bracket in error.

e.g.


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style>
div { 
background:red 
}
}
p { background:green }
</style>
</head>

<body>
<div><p>Test</p></div>
</body>
</html>


The CSS looks for a selector called “} p” and none exists so it moves on. Sometimes in Firefox this can stop any following rules working.

That’s why its important to validate the code and check for erroneous errors.