Efficient CSS

By on September 2, 2004

Here’s a nice article on writing more efficient CSS using shorthand properties, and reducing the number of duplicated style rules.

One of the touted benefits of CSS is that it reduces total page weight, and thus download time, both at first page load, and even more on subsequent loads due to style sheet caching. This is true, but often a sizable fraction of the first load savings is lost because of highly redundant CSS code.

The author lists the smaller stylesheet as the (marginal) benefit of taking the extra time to write efficient stylesheets, but in my experience, the bigger benefit is making things easier to change. If you want to change your site’s color scheme, it’s easier if the color rules are in as few places as possible.