In article <wMX89.5362$[EMAIL PROTECTED]>, unch wrote: > Hi, > > I'm trying to validate my css file to CSS2. I get a bunch of warnings > along the lines of: > > # Line : 43 Level : 1 You have no background-color with your color : a:link > > where A:LINK is defined like this: > > a:link { color:#000000; } > > I would like A:LINK to inherit the background color of BODY. How do I do > this without getting the above warning?
you can't. it is just a warning, which you can ignore if you want. it's not an error, it doesn't mean it doesn't validate - it's still valid, it just might cause problems with user styles. the reason for the warning is that you can't rely on inheritance to make a colour the one you expect. if a user has their own stylesheet, which overrides your BODY background colour, but not the link colours, then you might end up with something unreadable (e.g. if you set your BODY to be blue on white, and your links to be black, and the user sets the BODY to be white on black, but doesn't set link colours, then the links will take the black text from your style, and inherit the black background, leaving black-on-black). for that reason, the convention is to always set foreground and background together, so you always end up with either the author's colours, or the user's colours, but not a mix. > Naively, I tried: > > background-color: body.style.background-color > > But it has no effect and doesn't validate. you can't reference other properties like that. you can set it to be "inherit", but that's the default anyway, and you'll still get the warning. either explicitly specify the same colour as the background, or just ignore the warnings and hope nobody visits your page using a stylesheet of their own that doesn't mesh with yours. -- michael
