Section 14.1. Adding Comments


14.1. Adding Comments

When it's time to edit a style sheet weeks, months or even years after creating it, you may find yourself wondering "Why'd I create that style? What does it do?" As with any project, when building a Web site, you should keep notes of what you did and why. Fortunately, you don't need a pad of paper to do this. You can embed your notes right into your style sheets using CSS comments.

A CSS comment is simply a note contained within two sets of characters , /* and */. As with HTML comments, CSS comments aren't read or acted on by a Web browser, but they do let you add helpful reminders to your style sheets. Say you created a style intended to solve an Internet Explorer bug:

 * html .imageFloat {     display: inline; } 

At the time you wrote the style, you knew what you were doing, but will you still remember three months later? Add a comment and it'll be easy for you or someone else who needs to work on the site to figure out what the style does and why it was created:

  /* Fix IE 5 and 6 double-margin bug */  * html .imageFloat {     display: inline; } 

If you have a lot to say, comments can span multiple lines as well. Just begin with /*, type all the comments you'd like, then end with */. This is handy when adding background information at the beginning of a style sheet as pictured in Figure 14-1.

Figure 14-1. CSS comments can help you identify your styles for later editing. You can also use them to provide helpful introductory information that let's you keep track of the version of the site or style sheets, add copyright information, and identify yourself as the CSS master behind it all.



CSS[c] The Missing Manual
Dreamweaver CS3: The Missing Manual
ISBN: 0596510438
EAN: 2147483647
Year: 2007
Pages: 154

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net