W3C home > Mailing lists > Public > www-style@w3.org > January 1997

Re: Style sheet misuse advice

From: Hakon Lie <howcome@www10.w3.org>
Date: Wed, 29 Jan 1997 20:45:53 +0100 (MET)
Message-Id: <199701291945.UAA16075@www4.inria.fr>
To: john@htmlhelp.com
Cc: www-style@www10.w3.org, Urban Fredriksson <griffon@canit.se>, Liam Quinn <liam@htmlhelp.com>
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
color.

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

  A:LINK, A:VISITED, A:ACTIVE {
    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
style:

  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.

Regards,

-h&kon

H      k   o   n      W   i   u   m       L   i   e
howcome@w3.org   W o r l d   Wide  W e b  Consortium
inria # FRANCE http://www.w3.org/people/howcome
Received on Wednesday, 29 January 1997 14:46:33 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Monday, 27 April 2009 13:53:46 GMT