How to write style sheets (CSS)

If you wish to use Cascading Style Sheets on Web pages, here's a suggestion on how to do it, especially how to solve problems or preferably avoid them. The discussion here is limited to CSS1, since CSS2 has been implemented to a small extent only. It is assumed that you have read some introduction to style sheets, such as WDG's CSS Quick Tutorial or Dave Raggett's Adding a touch of style.

  1. Create your HTML document(s) according to good authoring principles.
  2. When you have an idea about a presentational suggestion, check from WDG's reference CSS Properties whether there is a property which can be used and how it is to be used. That way you'll find reliable information about how it should work, by the specs.
  3. Check the implementation status for the features you are going to use, from the Master Compatibility Chart by Note that being not supported ("N" in the table) is not that serious but buggy ("B") implementations are.
  4. If you decide to use CSS for your purposes, write a style sheet according the specifications and associate it with your HTML document.
  5. Check your HTML document using a validator. (Naturally, you used a validator already at step 1. You need to validate again, since you have added something to your HTML document in order to associate a style sheet with it.)
  6. Check your style sheet using a CSS checker. It is practically certain that you make lots of mistakes in your CSS code, and a checker is therefore indispensable.
  7. Having done that, and having fixed the errors and re-checked your code, see how the document looks like on some browsers. Preferably, test it on all major versions of IE and Netscape from version 3 onwards and on Opera.
  8. If problems remain, and you can't find an answer e.g. by using the documents listed under CSS Pointers, consider asking for help in the newsgroup comp.infosystems.www.authoring.stylesheets. Please remember to tell the URL of your page, check the FAQ before posting, and use good Usenet style.