Re: missing background-color

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: missing background-color

John V. Harris
I am thinking it is probably time to create some kind of Version string that I can place in my CSS block indicating which version of the standard it was validated against.
 
I have determined that ALL of the warnings I am getting can be suppressed by including "background-color: inherit" into the rule for each selector where I haven't otherwise specified a background-color.  I actually have a problem doing that, because the common browsers don't seem to have adopted CSS2, and the keyword "inherit" was not a part of CSS1.  Therefore, the inclusion of that keyword would be done ONLY to satisfy your validator, and I am not willing to rewrite a bunch of pages everytime you change things.
 
If we could include a version string, then your validator would be a bit more useful.  As it is NOW, it is like the "boy who cried wolf"...it is difficult to see REAL warnings amidst all the garbage.
 
FURTHERMORE, any warning about not including a background-color when I specify a color seems to indicate a tendency to remove "Cascading" from "Cascading Style Sheets".  Can we expect to eventually see "Warning: you specified a font-weight without specifying a font-family, color, or font-size"????
 
JohnV
Head Honcho
The Zone Gazette
Reply | Threaded
Open this post in threaded view
|

Re: missing background-color

Jukka K. Korpela

On Sat, 12 Nov 2005, John V. Harris wrote:

> I am thinking it is probably time to create some kind of Version string
> that I can place in my CSS block indicating which version of the
> standard it was validated against.

There is no standard. Even if there were, the idea would be pointless,
since nobody should trust such "indicator", any more than anyone should
trust a "Valid HTML!", "Valid CSS!", or "WCAG 1.0!" label.

> I have determined that ALL of the warnings I am getting can be
> suppressed by including "background-color: inherit" into the rule for
> each selector where I haven't otherwise specified a background-color.

Are you aiming at getting a warning-free report as a _goal_ in itself?
Then use an empty style sheet.

> I actually have a problem doing that, because the common browsers don't
> seem to have adopted CSS2, and the keyword "inherit" was not a part of
> CSS1.

The real problem with it is that you would get as unpredictable results
as by not setting background color. Besides, inherit is the initial value.
Anyway, the element would inherit its background color from its parent
element, and you cannot know which color that is.

> Therefore, the inclusion of that keyword would be done ONLY to
> satisfy your validator,

So why would you do that? The "CSS Validator" gives a useful warning.
You can ignore it, you can refrain from using the program at all,
or you can make some use of it.

> As it is NOW, it is like the "boy who cried wolf"...it
> is difficult to see REAL warnings amidst all the garbage.

The real warnings are about things you would not notice otherwise.
Clearly, the background color warnings belong to this category.

> FURTHERMORE, any warning about not including a background-color when I
> specify a color seems to indicate a tendency to remove "Cascading" from
> "Cascading Style Sheets".

People who complain about it do not understand the "Cascading" part of
CSS.

Have you _ever_ thought what happens when your style sheet is applied
in conjunction with other style sheets, such as a browser's default style
sheet or a user style sheet, which can contain just anything?

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


Reply | Threaded
Open this post in threaded view
|

Re: missing background-color

Philip Taylor (Webmaster, Ret'd)



Jukka K. Korpela wrote:

[snip]

> Are you aiming at getting a warning-free report as a _goal_ in itself?
> Then use an empty style sheet.

It's not quite as simple as that --

        W3C CSS Validator Results for http://www.rhul.ac.uk/resources/examples/empty.css
        No error or warning found

        To work as intended, your CSS style sheet needs a correct document parse tree.
        This means you should use valid HTML.
        No style sheet found

All of the last three lines are apparently intended to
cast fear into the hearts of the foolish, so even
an empty style sheet can still cause the validator
to issue "diagnostics" which suggest (to the
uninitiated) that "all is not as it should be" ...

Philip Taylor

Reply | Threaded
Open this post in threaded view
|

Re: missing background-color

Ian Hickson
In reply to this post by Jukka K. Korpela

On Sun, 13 Nov 2005, Jukka K. Korpela wrote:
>
> Besides, inherit is the initial value. Anyway, the element would inherit
> its background color from its parent element, and you cannot know which
> color that is.

The initial value of 'background-color' is 'transparent', not 'inherit'.

Elements don't inherit any background color. The problem is that an
element with a color set and not a background color set can have a color
and background color set from a user stylesheet, where the end result has
the element's color coming from the author stylesheet and the background
color coming from the user stylesheet, and since those colors were picked
by different people they might be the same and make the text go invisible.

The solution is to set 'background: transparent' whenever setting 'color',
if you have colors set all the way back to the root element (explicitly as
'background: transparent; color: inherit' if you want the default
behaviour); otherwise, the solution is to set both 'background' and
'color' to non-transparent, non-inherit values.

--
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Reply | Threaded
Open this post in threaded view
|

Re: missing background-color

Jukka K. Korpela

On Sun, 13 Nov 2005, Ian Hickson wrote:

> The initial value of 'background-color' is 'transparent', not 'inherit'.

Thanks for the correction. The basic problem is the same: by setting the
background-color property to either of these values or defaulting it
means that you get whatever background is specified for the parent
element. And that's not under the author's control; he may say something
about it, but his opinion may be overruled. That's natural, but problems
arise when the author has suggested content color and this suggestion is
_not_ overruled.

> The problem is that an
> element with a color set and not a background color set can have a color
> and background color set from a user stylesheet, where the end result has
> the element's color coming from the author stylesheet and the background
> color coming from the user stylesheet, and since those colors were picked
> by different people they might be the same and make the text go invisible.

Indeed. This what most authors seem to miss, when this issue is discussed.

> The solution is to set 'background: transparent' whenever setting 'color',
> if you have colors set all the way back to the root element (explicitly as
> 'background: transparent; color: inherit' if you want the default
> behaviour); otherwise, the solution is to set both 'background' and
> 'color' to non-transparent, non-inherit values.

I'm afraid only the latter solution is reliable. One reason to this is
that the value 'inherit' is not supported by the most common browser.
Using 'transparent', even when set explicitly, isn't reliable either, for
a different reason.

Suppose that you have just <body>, <p> and <strong>, nested in the obvious
way. If you set
strong { color: black; background: transparent; }
then what happens if the user style sheet is
body, p { background: black; color: white; }
which is, as such, a technically correct style sheet. (If you wonder why
anyone would use it, think about all the authors that seem to love
black background. Surely they may some day invent the possibility of
looking at others' pages that way too. Besides, there are people with
a rare vision impairment that makes it easier to read white on black than
black on white.)

If you set
strong { color: black; background: yellow; }
for example, there will still be problems if a user style sheet has, say,
strong { color: yellow; }
but this is a technically wrong style sheet and it is a problem that
the user created and needs to solve. Authors should take precautions
against all imagineable _correctly written_ browser/user style sheets.

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


Reply | Threaded
Open this post in threaded view
|

Re: missing background-color

John V. Harris
It seems to me you are creating a lot of fuss over a "what if".  IF somebody wants to create a user stylesheet to present my page more to their liking, it is really up to THAT person to twiddle things to suit them.
 
What you seem to be saying is that if I invite you over to my house, and you decide to rearrange the furniture, I should have the foresight to put an extra long cord on ALL lamps so you can put anything wherever you want?
 
As the designer of the page, I would like to make use of the Cascading nature of CSS.  If I decide I want a DIFFERENT background-color, I should be able to change the background-color of the PARENT, without having to change every other thing contained in that element.
 
ALSO, if I have several classes where I change the color for effect, you would have me create an ADDITIONAL class for each item I want to use against a different background-color, rather than just verify that the color I have chosen contrasts the visible background wherever it is used?
 
JohnV
Head Honcho
The Zone Gazette
Reply | Threaded
Open this post in threaded view
|

Re: missing background-color

Bjoern Hoehrmann

* John V. Harris wrote:
>It seems to me you are creating a lot of fuss over a "what if".

The Validator's primary job is to help better make better content. Here
the Validator points out that if you always set background-color and
color together, the style sheet is more likely to interact well with
e.g. user style sheets, which is considered a good thing.

If you want the Validator to not tell you that you would have to argue
that setting color and background-color together does not help make the
style sheets better, or that this case is unimportant compared to other
issues yet the presentation of this particular warning is such that the
other warnings are more difficult to follow.

It does not really help if you explain that you don't care much about
the warning, since in that case you can turn warnings off or simply
ignore this warning.
--
Bj?rn H?hrmann ? mailto:[hidden email] ? http://bjoern.hoehrmann.de
Weinh. Str. 22 ? Telefon: +49(0)621/4309674 ? http://www.bjoernsworld.de
68309 Mannheim ? PGP Pub. KeyID: 0xA4357E78 ? http://www.websitedev.de/ 

Reply | Threaded
Open this post in threaded view
|

Re: missing background-color

John V. Harris
Sorry, but there is no option to turn off just ONE type of warning.  You have to turn them ALL off.  I am interested in warnings that make SENSE to me.  Ignoring this warning is difficult, since there are maybe 50 copies of the same thing, possibly interspersed with one or two warnings I want to correct.
 
As a C++ programmer, I don't get a warning for each method of the base class that I didn't override in the derived class.  I can override whichever ones I choose to override.  Same with CSS.  If I WANT the parent's background-color, I should NOT have to specify a background-color.
 
A WARNING indicates to me that something COULD be done better.  I disagree that this warning is doing me any such service.  For this type of warning, the validator might be doing a BETTER job if it collected a count and said something like "you specified a color without a background color 875 times...we don't RECOMMEND doing this.  Click here to see a list of the lines this warning refers to."
 
JohnV
Head Honcho
The Zone Gazette