PDA

View Full Version : CSS validator warning


dthomsen8
03-19-2006, 06:17 AM
<H2>Warnings

URI : http://www.19121.com/twocol.css


Line : 8 (Level : 1) You have no color with your background-color : body
Line : 15 (Level : 1) You have no color with your background-color : #header


Valid CSS information


body {

padding-right : 0;
padding-left : 0;
padding-bottom : 0;
margin : 0;
padding-top : 0;
background-color : #99cccc;
font-size : 100%;
font-family : Arial, Tahoma, Helvetica, sans-serif;
}
#header {

height : 110px;
background-color : white;
min-width : 740px;
}

</H2>
The w3.org CSS validator says I don't have a background color, but only as a warning. What is the problem?

iamback
03-19-2006, 06:20 AM
The w3.org CSS validator says I don't have a background color, but only as a warning. What is the problem?The problem is that you don't know what the visitor has configured as a window background color on their own system. Their window background color combined with your body (text and lines) color could result in totally illegible or even invisible text.

dthomsen8
03-19-2006, 07:51 AM
The problem is that you don't know what the visitor has configured as a window background color on their own system. Their window background color combined with your body (text and lines) color could result in totally illegible or even invisible text.

Quite true, it could have that result, but that doesn't explain the CSS Validator warnings, or does it?

What could I possibily specify which would satisfy the Validator?

ktinkel
03-19-2006, 09:00 AM
Quite true, it could have that result, but that doesn't explain the CSS Validator warnings, or does it?

What could I possibily specify which would satisfy the Validator?Add color: #000000; to body; add color: inherit; to #header (or a different color if you are using colored type).

iamback
03-19-2006, 12:04 PM
Quite true, it could have that result, but that doesn't explain the CSS Validator warnings, or does it?Yes it does - that's exactly the reason for the warning: if you specify color but not background color, the legibility of the actual result will be unpredictable. Basically it's a warning that there may be a usability / accessibility problem if you don't specify both together.

What could I possibily specify which would satisfy the Validator?To satisfy the validator, any color will do. To satisfy your visitors is more important - specify a background color that provides sufficient contrast with the color property (but preferably not pure white for black text since that forms a usability problem in its own right).

You can specify "inherit" for body background color if - and only if - you have a background color set for the html element with the same properties as indicated above.

Sidenote: Few people realize that you can style the html element - but you can; you can use that to make a nice border around your page, for instance: give html a different background color than body, and set both padding and margin to zero; then set margin for body to the width of the border you want to create.