There are several reasons why you might want to place comments in your stylesheets. One reason is that you may wish to document why you have coded a particular value in your stylesheet so that you can remember what it is for and where you have used it. A second reason is to comment out some style definitions that you want to remove from the stylesheet temporarily perhaps so that you can see what affect certain changes have before making them final. You can probably think of several more reasons why you would want to add comments to your stylesheets.

Comments are added to stylesheets in the same way that comments are added in many programming languages such as C++ or Javascript except that CSS does not have single line comments. Surrounding anything with /* */ will effectively comment out everything contained within it whether this extends over part of a line or multiple lines.

li {color:red;} /* multiple line
comment */


This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow