Trim your CSS

If you’re not careful when developing a website, you may end up with a bloated CSS file that is easy to get lost in and difficult to maintain. It will also add to total page weight, taking away some of the advantage of having nice and clean HTML. From personal experience I can tell you that a CSS file for a large and complex website can end up containing quite a bit of redundant code.

If you get rid of that code and clean up your CSS file, it will be easier to come back to and make changes, and you will save some bandwidth. John Gallant (a.k.a. Big John) and Holly Bergevin tell you how in Writing Efficient CSS at Community MX. Methods include shorthand properties, multiple declarations, default values, inheritance and white space.

Posted on December 3, 2003 in CSS