1. Computing & Technology

Discuss in my forum

Jennifer Kyrnin

Poll: Do you comment your CSS?

By , About.com GuideNovember 18, 2010

Follow me on:

Adding comments to your CSS is a really useful way to make your CSS easier to use in the future. I like to create sections in my CSS and comment them, and then add comments at the end of important or confusing lines so that I know what they do in six months. But some people don't like to include comments because it can add to the download time. If speed is important then removing comments is important too.

Comments
November 18, 2010 at 5:40 am
(1) Warehouse Inventory says:

Thank
I adore your website – nice job!

November 20, 2010 at 11:27 am
(2) Alexander says:

I like to keep my CSS nicely formatted and readable, so I don’t waste my time in documenting it for future developers, that in my opinion should know what it does once they take a look at it (of course, that’s why I keep it organized and readable).

If the future developers need documentation on my CSS I’ll leave it up to them to create whatever comments they need.

Of course, this is not the friendliest approach, but I wouldn’t complain if I get a non-commented, but well made CSS file.

November 21, 2010 at 8:07 am
(3) Usman Zuberi says:

Well commenting a css is a good technique. I design websites and do freelance projects.

November 23, 2010 at 9:49 am
(4) Randy Carey says:

My background is in the software development field where indenting and commenting is expected. I always comment my CSS.

But these days I develop sites on a framework called Gantry. This backend tool automatically takes all my CSS files and compile them into a single file, stripping out all comments. So web pages call a streamlined CSS file with no comments, but as I develop with files where the comments remain intact. Best of both worlds.

Leave a Comment

Line and paragraph breaks are automatic. Some HTML allowed: <a href="" title="">, <b>, <i>, <strike>

©2012 About.com. All rights reserved.

A part of The New York Times Company.