CSS guidelines

I took an action item a month ago to research CSS guidelines that we
could mention in the techniques document.

I asked Bert Bos, one of the author of CSS here at W3C, and he pointed
me at a chapter of his and Hakon Lie's new book on CSS2.

Bert has been kind enough to let me reproduce this chapter in this
forum and is looking forward to your feedback on this list.
I put a copy (without the images) at
     http://www.w3.org/WAI/GL/css2em.htm

There is also a page by Jakob Nielsen, with the kind of solid advice
that you can expect of him:
     http://www.useit.com/alertbox/9707a.html

I took those two documents and summarize them along the following
lines:

- Use a minimal number of style sheet for your site 
  
- If you have more than one, use the same CLASS names for the same
  concept in all of the style sheets. 

- Use linked style sheets rather than embedded styles, and avoid
  inline style.

- Do not use the !important attribute (CSS1 only, since CSS2 gives
  priority to users anyway)

- Always use ems to set font sizes
   H1 { font-size: 2em }

- Use relative units for lengths (%, em, for padding, margin)
   BODY { margin-left: 15%; margin-right: 10%}

- Only use absolute length units when the physical characteristics of
  the output medium are know
   .businesscard { font-size: 8pt }

- Always specify a fallback generic font 
   BODY { font-family: "Gill Sans", sans-serif }

- Use numbers, not names, for colors 
   H1 {color: #808000}
   H1 {color: rgb(50%,50%,0%)}


Other things, like

- Use floating elements instead of tables
- Put content in its logical order 
- Make sure your documents are legible without style sheets 

are already covered in the guidelines.

Received on Monday, 15 February 1999 09:55:43 UTC