Re: a simple question

Ian Hickson wrote:
> Well, 'transparent' *can* be used, provided everyone follows Todd's
> "reasonable and prudent" notion.

Let me try and expand this notion a bit, and see what you all think of
the specifics.  I've been thinking about this issue (since before the
discussion), and I think I'm currently leaning towards the following:

1. color/background pairs should *always* be specified together so that
no rules from another origin may get between them in the cascade.  They
may have different specificities, for example:

H1 {
   background: black;
   color: white;
   }

H1.warn {
        color: red;
		}

would be acceptable.  They should never be different weights, because
then levels of cascading can conflict (even in author stylesheets, for
CSS1 compatibility).

2. User stylesheets, whenever they specify colors with non-important
weight, should specify color/background pairs without using inherit or
transparent.

3. If user stylesheets specify any color/background pair with
important weight for an element, then they should specify the same
color for all descendants (using the universal selector and possibly
other selectors) of the element and transparent (not inherit) for all
descendants of the element.  Trasparent should be used so that
positioning does not lead to covering of text.  For example:

P {
  color: black ! important;
  background: white none ! important;
  }

P * {
  color: black ! important;
  background: transparent none ! important;
  }

P A:link { color: blue ! important; }
P A:visited { color: purple ! important; }
P A:active { color: red ! important; }

4. Author stylesheets should always specify color/background in pairs.
However, given the rules above, authors can use inherit or transparent,
provided they have explicitly set the background (or color, if
inheriting color) on the parent element.  The color is explicitly set
on an element even if inherit or transparent is used, as long as the
color/background of the parent of that element was also explicitly set
(a nice recursive definition).  Thus if a user stylesheet overrides the
color on which the author depends (using inherit/transparent), the user
stylesheet will also override the colors of the element where the
author creates this dependence.  Thus there would be no problem.

This allows authors to use transparency, which is often needed for good
use of absolute positioning.

5. The rule

(any selector) {
  color: inherit;
  background: transparent none;
  }

is always acceptable, for any weight, origin, or selector.  (Perhaps
there are some somewhat obscure reasons why one might want this.)

What do you think of these rules?  I'm working on a web page on user
stylesheets (if I ever have time to write the rest of it), and I hope
to include guidelines along these lines.

David Baron

-----------------------------------------------------------------
L. David Baron    Freshman, Harvard    dbaron@fas.harvard.edu
Links, SatPix, CSS, etc.  < http://www.fas.harvard.edu/~dbaron/ >
WSP CSS AC                < http://www.webstandards.org/css/ >

Received on Tuesday, 9 March 1999 12:17:39 UTC