View Full Version : Color and Background Color
primexx
11-16-2005, 06:43 AM
The Validator insists that a colour and background colour be specified together, what would I do if I want the background colour to inherit from the containing div?
Bill Posters
11-16-2005, 08:23 AM
The Validator insists that a colour and background colour be specified together, what would I do if I want the background colour to inherit from the containing div?
Fwiw, it's not an invalidation, it's a warning. The CSS still validates, but the validator can't verify that your use of text colours and background colours provide sufficient contrast for user to be able to read the text.
The warning is simply a heads up for you to ensure that there aren't any instances where the text cannot be read over the background colour.
(In case you weren't aware, these warnings are only triggered when you declare either the color property, but no background-color property - or the background-color property but no color property.)
To 'inherit' the background-color from a parent element…
selector {
background-color: inherit;
}
Inheriting the background colour of a parent element may not always be desirable as it may cause elements to obscure background images used in parent elements.
In such a case, you can choose not to declare a background colour and live with the warnings, if any are mentioned.
(The transparent value for the background-color property will still lead to the same warnings you get had you not declared any background-color property at all.)
So long as you are certain that your use of colours, background colours and background images provides sufficient contrast to be readable, then you can ignore the warnings.
To be more thorough, you should be sure to check that your page remains readable with CSS 'on' and images 'off'.
mrruben5
11-16-2005, 08:30 AM
I wonder, will the validator still give a warning if you give it a background-color: transparent ?
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.