CSS optimization is the process of minimizing your markup and CSS files for maximum speed. You can employ some of the same techniques to optimize CSS that you learned in Chapter 3, "HTML Optimization." Whitespace removal, cutting comments, crunching color values, and embedding code with SSI are some of the techniques common to both CSS and HTML optimization. CSS gives you more flexibility than HTML or XHTML, however, because you can make up your own names and group rules together to save space.
You'll reap the greatest rewards by using CSS to transform your code into a more rule-based modus operandi. Converting old-style table/font layouts into XHTML/CSS-style code typically saves 25 to 50 percent off file sizes and gives you the benefits of adaptable structure and separate presentation. You can use layering and inheritance to save space and increase compatibility, and use shorthand properties to shrink your CSS code by up to 50 percent. This chapter gives you the tools you need to optimize your CSS.
In Chapter 8, "Advanced CSS Optimization," you'll put these techniques to work with real-world examples showing substitution and optimization in action.
This chapter assumes you have some familiarity with CSS. To learn CSS, I recommend Cascading Style Sheets: The Definitive Guide by Eric A. Meyer (O'Reilly, 2000), Eric Meyer on CSS (New Riders, 2002), and Designing CSS Web Pages by Christopher Schmitt (New Riders, 2002).