W3C home > Mailing lists > Public > www-validator-css@w3.org > January 2010

Re: CSS validator complaining about no background-color when I clearly have one

From: Jukka K. Korpela <jkorpela@cs.tut.fi>
Date: Sun, 3 Jan 2010 21:12:42 +0200
Message-ID: <81FD64490AAA48A09FDBCD8E269085AD@JukanPC>
To: "Paul Kimelman" <paul@nikoosha.com>, <www-validator-css@w3.org>
Paul Kimelman wrote:

> The CSS validator does not seem to know about body background-color

Au contraire, it knows more about it than most web page authors.

>      and I am not sure why. I have a whole bunch of warnings starting
> with: 44 #autoXML12081691208169  You have no background-color set (or
> background-color is set to transparent) but you have set a color.


> Make sure that cascading of colors keeps the text reasonably legible.

The cascade is the most commonly misunderstood of all CSS concepts, so that 
note is of questionable value.

> But, it accepts that the 1st css element is:
> body {
> margin : 0 0 0 0;
> background-color : #ffddee;
> color : black;
> }

It's a rule, not an element (there are no elements in CSS, just notations 
that refer to elements). And it sets properties for the body element.

> It would seem that the body background color flows downwards.

It would seem to, but the "W3C CSS Validator" is implicitly referring to 
better knowledge.

> The next level is a div with another background-color and inherits the
> foreground.

Automatic inheritance only takes place when no style sheet being applied 
assigns a value for a property of an element.

Consider, for example, what happens when the browser applies, in addition to 
your style sheet, the following user style sheet:
* { background: black; color: white; }
(which could be a useful part of a user style for a user suffering from 
eyesight problem due to which white on black is much more legible than black 
on white).

Just in case this isn't obvious enough: for your div#main, the background 
property is taken from your style sheet, because it's an author style sheet, 
but the color property is taken from the user style sheet.

Yucca, http://www.cs.tut.fi/~jkorpela/ 
Received on Sunday, 3 January 2010 19:13:56 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:40:46 UTC