commenting in CSS

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

does anyone know how you can make comments in CSS?

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

wait... I got it. Just had to play with it for a minute...
C style comment tags, and not the //, they seem to mess it up

a { color: 00c6ff; text-decoration: none; }
a:hover { color: 00ffff; }

/*
this is a comment
that spans multiple lines
*/

.home_title { font-size: 16pt; font-family: arial; }
.home_sectiontitle { font-size: 14pt; font-family: arial; }

blah blah blah
'

also, just putting text in there like I did at the bottom seems to be ok. I don't believe that that is the proper way, but right now it doesn't seem to effect anything.

Mark Hensler
If there is no answer on Google, then there is no question.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

Smiling What a tough sell _you_ are!

/* comment */ is the way to comment CSS, you are right! However the text at the end may cause some issues depending on where you put it. If you have in in a local stylesheet (on the HTML page) then it should be commented out by the HTML comments anyway within the tags.

In an external stylesheet, it may just screw up lower browsers.

In all cases, the CSS won't validate with loose text floating around.

Congratulations, though, on figuring it out, even if you don't believe it! Smiling

Suzanne

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Is /*this*/ the only way to comment then?
I would of thought that // would have worked (being another C comment method) but it doesn't seem to.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

I don't know why, I just know that /* comment */ is the only way to do it in CSS.

Unlike JavaScript where you can use both, but people commonly only use //.

Weird.

Smiling Suzanne

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.