- Prefer Styles to HTML Tags
- Encapsulate Styles
- Use Cascading Wisely
- Coding Style
Maintaining CSS style sheets separately from content files allows the use of the same styles in multiple documents or applications more easily. For example, a company might formalize a corporate standard for the look of HTML documents in a set of style sheets. If maintained in external files, all documents published on the company's Web site could easily apply the standard styles simply by linking to them. Even documents published before the standard can easily be updated to bring them into compliance by adding a link to the external style sheet files.
Maintaining styles in external files also reduces code duplication and makes maintenance much easier. An update made to a style in a single place automatically is propagated to all documents that use the file.
Remember that the browser must download all the styles defined in a linked external file, even those not used by the Web document. This is a waste of processing power and network bandwidth, so it is important to structure external style sheet files wisely. Keep related styles together for easier maintenance, but try not to include many seldom-used styles.
Shared Style Sheets
The separation of content from style makes it easy to implement styles prepared by a third party. For example, the W3C makes some global shared style sheets available from the organization's Web site. These styles consist of carefully designed combinations of fonts, colors, and borders that enable document authors to use high-quality styles without having to master CSS.
At the time of this writing, eight different standard W3C style sheets are available for document authors to link into their documents. For more information and detailed instructions, see the W3C's Web site at http://www.w3c.org/Stylesheets/Core/.