Skip to: content, navigation

by Tommy Olsson and Paul O’Brien

CSS Comments

In CSS, a comment starts with /* and ends with */. Comments can span multiple lines, but may not be nested:

/* This is a single-line comment */

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

According to the CSS2 specification, comments that appear between tokens won’t have any effect on the styles’ rendering. In practice, however, we find comments causing errors in some older browsers in certain situations.

Comment Syntax

The // comment syntax used in C++ is not allowed. Neither are SGML comments that take the form <!---->, except in one situation: they may appear in internal style sheets—style sheets placed within the HTML source using the <style> tag—in order to hide the CSS statements from pre-HTML4 user agents. However, this use of comments is now redundant and can be disregarded. See Linking CSS to a Web Document for further information.

User-contributed notes

There are no comments yet.

Add a note

To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters