Setting CSS property to another

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I was validating some CSS last night and kept getting warnings that my
TD styles had a 'background-color' but no 'color.'  I didn't have one
because I wanted the text to be the color specified in the page's style
sheet.  I thought that was the idea of CSS - styles "cascade" down and
any property not found for a particular tag at that level are then
searched for at higher levels of the DOM structure.

Anyway, for the sake of having the CSS validate without warnings, I
want to add color properties for the tags that need them.  But for sake
of maintainability, can you set one CSS property equal to another so
you don't have to hunt down all the properties and change their values?
 For example,

  background-color: #000088;
  color: #0000FF;

  background-color: #000044;
  color: body.color;

This is sort of what I am after but I haven't found any info on it
online and have no idea what the syntax would be, if it is even
possible.  I've seen this asked in newsgroups (including this one) but
no one ever seems to answer the question.  Does anyone know if this can
be done?


Re: Setting CSS property to another a écrit :
Quoted text here. Click to load it

It's just that once you have define a background-color, you need to
define the color too (or vice versa). What makes a text legible is that
there is enough contrast between background-color and color to make it

W3C Quality Assurance tip for Webmasters:
If You Pick One Color, Pick Them All

  I didn't have one
Quoted text here. Click to load it

Yes, that's how inheritable properties work. Not all properties are
inheritable; not all properties are inherited from containers if they
are not specifically defined.
Every listed CSS 2.x property has a field indicating whether it is or
not inherited.

Quoted text here. Click to load it

That is light blue.

Quoted text here. Click to load it

color blue is not best. blue on light blue is not that contrasting, easy
to distinguish, to read.

Effective Color Contrast

The default color for unvisited links is set to blue in all modern
browsers. Personally, I would avoid doing that.

Quoted text here. Click to load it

color: inherit;

     Value:      <color> | inherit
     Initial:      depends on user agent

6.2.1 The 'inherit' value

remove blah to email me

Re: Setting CSS property to another

Those colors were just quick examples that I wrote - not the actual
colors on my site.  Your response about 'inherit' was dead on though.
Exactly what I was looking for I believe.  Thank you very much.

Re: Setting CSS property to another

On 8 Oct 2005 11:28:49 -0700, wrote:

Quoted text here. Click to load it

Take a look at these I asked the same question of W3c :

Site Timeline