Re: Style sheet misuse advice

John Pozadzides writes:

 > If one were to set Text and Link colors using a style sheet, should one
 > also define the background colors for these elements as well?

Thanks for posting the question, it's an interesting one and should go
into the FAQs. I'd say you should set give 'background' a value, but
not necessarily a color value. E.g., if the document has a background
image, you would "hi-light" all links if you give them a background

  BODY {
    background: url(light-texture.png) #FFF;
    color: #000 }

    color: #00F;
    background: transparent;

By setting the 'background' explicitly to 'transparent', you lower the
risk of another rule in the cascade giving links a background that
would hi-light them.

The next question is: If 'background' and 'color' always should be set
together, why do they exist as separate properties?

There are serveral reasons for this. First, style sheets become more
legible -- both for humans and machines. The 'background' property is
already the most complex property in CSS1 and combining it with color
would make it even more complex. Second, 'color' inherits, but
'background' doesn't and this would be a source of confusion. Third,
in the discussions within the W3C HTML ERB this fall, several people
wanted to split the compound properties into their smaller parts. The
result was a number of new background-*, border-* and list-style-*
properties. (BTW, Bert and I resisted these changes but lost)

A meta-question that should also be asked is how to best write style
sheets to accomodate cascading. From a forthcoming book on CSS, Here
is one of around ten "guidelines" on how to write style sheets with

  Design to Accommodate Cascading

  Realize that some users will have personal style preferences when
  reading your documents. Write your style sheets so that a user's
  personal sheet will cascade gracefully with yours. You can help with
  this by setting properties in recommended places. Style rules that
  apply to the whole document should e.g. be set on the BODY element --
  and only there. In this way, the user can easily modify document-wide
  style settings.



H      k   o   n      W   i   u   m       L   i   e   W o r l d   Wide  W e b  Consortium
inria # FRANCE

Received on Wednesday, 29 January 1997 14:46:33 UTC