Home CSS Comments CSS Comments Describe Formatting
Search MS Office A-Z   |   Search Web Pages/ Design A-Z

CSS Comments Describe Formatting

Answer the second question "why did I do that" with CSS comments.

Style definitions can get pretty complicated. It's easy to get confused about a particular definition - especially when you're using an external style sheet to control formatting for an entire Web site.

Suppose you create a class that's only going to apply to a single page. It would be helpful to note which page it's used on and why. But for that, you need to use CSS comments, not HTML comments. Like this comment that describes how pull quotes on the home page will look:

/* Div for pull quotes on home page - yellow background, bold, green text, solid, 2px border */

Your CSS comments can be several lines long and as detailed as you need. Place them anywhere inside your opening and closing STYLE tags, but never inside a style rule.

You may also find CSS comments helpful when you're trying to debug your style definitions. Place comments around troublesome sections inside your style sheet and test the pages without those rules applied. That's a good way to isolate problems with inheritance or conflicting style rules.