Re: CSS Validation warning: You have no background-color with your color;

On Thu, 23 Feb 2006, olivier Thereaux wrote:

> On 21 Feb 2006, at 21:07, Jukka K. Korpela wrote:
>> 
>> Anyway, the FAQ entry
>> http://www.websitedev.de/css/validator-faq#color
>> explains the issue, though rather compactly:
>> "If you don't specify color and  background-color at the same level of 
>> specifity, your style sheet might clash with user style sheets."
>> Besides, it's not the whole truth.
>
> The FAQ could probably be updated to
> - mention in more details the fact that the warning is not one of conformance 
> to CSS, but one of accessibility.

Labeling it as "accessibility" wouldn't be quite adequate. If the checker
warned, say, about too small contrast between background and text color, 
_that_ would be about accessibility. The risk of _arbitrary_ combination
of background and text color is about robustness. If the colors are, for 
example, exactly the same, you don't need to be visually impaired to miss 
information.

> - stress the fact that it is a suggestion, not an error (somebody today told 
> me that it would make fewer people ill at ease if the wording was less harsh)

Actually the wording _should_ be stronger, as we can deduce from the 
protests against the warning - regularly reflecting lack of 
understanding the issue, even after explanations. It's called a warning, 
and that should suffice, unless you wish to make it _strong_ warning.

The _heading_ of the explanation is somewhat misleading, however. It 
contributes to the common misconception about a "nagging" "validator" when 
it uses the verb "complain". The verb "warn" would be more adequate.

Of course, giving the checker a more adequate name, instead of 
misrepresenting it as a validator, would help in general. But it seems 
that such an action will not be taken.

> - mention that the problem could be caused by cascading, maybe give a short 
> example

Just mentioning cascading would not help much, since most author keep 
misunderstanding how the cascade works.

> Anyone interested in drafting a wording for 
> the extended section?

Since the warning is so commonly misunderstood (and therefore criticized), 
even after attempts at helpful explanations, I'm afraid there is no simple 
and short explanation that would suffice.

START PROPOSED TEXT
If you assign a value to the color property without simultaneously assigning
a value to the background-color property, unreadable or otherwise 
undesired color combinations may appear. The reason is that your style 
sheet may be applied together with a user style sheet (or a browser style 
sheet, or another author style sheet). Even if the other style sheet 
is well-designed, CSS principles may imply that the color is taken from 
one style sheet and the background-color from another. This may result in 
black text on black background, for example.

Specifying background-color: transparent is not sufficient for avoiding 
the problem. Consider the following example:

body { background: white; color: black; }
h1   { color: #060; background: transparent; }

Assuming that h1 appears as a subelement of body, this results in h1 
displayed in color #060 (dark green) on white background, which is the 
background of body shining through. However, if a user style sheet 
contains

body { background: #060 !important; color: white !important; }

then the background of body that shines through will be #060, making the 
heading text completely invisible.

Thus, it is normally best to rewrite the style sheet so that background
colors are set explicitly, even though this causes some inconvenience.
In rare cases, it might be possible to analyze reliably that the risk 
described here does not exist or that it is worth taking.

Technically, this message is a warning, not an error message, since taking 
the risk does not violate any requirement in CSS specifications.
END PROPOSED TEXT

This could be followed by a paragraph containing the second half of the 
current explanation, reworded e.g. as "For more information, consult 
Section 9.1 "Color Contrast" in the W3C Note "CSS Techniques for Web 
Content Accessibility Guidelines 1.0" or the article CSS Color Issues by 
the CSS Pointers Group for a discussion."

-- 
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/

Received on Thursday, 23 February 2006 15:35:16 UTC