Share via


Compile time error: "[value] is not a valid value for the 'color' (or 'background-color') property

Question

Friday, January 19, 2007 2:06 PM

Greetings:

 Have tried searching for anything to do with this error message and I either get far too many results to search or nothing at all. So here's the problem.

In a CSS style sheet I have built various styles selecting colours from the IDE's color picker/web colors tab. Two of the colors for example are 'named' "cornflower blue" and "crimson". If I preview a page in the browser with styles containing these 'values' (which are written into the style sheet as their names not Hex or RGB values), everything is fine. But if I run the app in debug...the compiler with throw these errors:

Error 2 'crimson' is not a valid value for the 'color' property. 

Error 3 'lightgrey' is not a valid value for the 'color' property. 

Error 4 'cornflowerblue' is not a valid value for the 'background-color' property.

There are 9 total, but some of them are repeats, but I think this exemplifies the problem well enough.

 I find nowhere to discover the hex values for these 'named colors' so that I might substitute those values for the names, but it seems rather odd that a development tool that is going to allow you to 'choose' what appears to be a system constant, doesn't actually recognize them. Can anyone explain what's happening here and how I might go about finding out the hex values for these colors so that I can specify those in the style sheet instead of these names?

All replies (1)

Friday, January 19, 2007 11:13 PM

Those color names, although supported by most browsers, are NOT standard. CSS2.x only allows 16 color names. CSS3 (draft) has names for all 256 colors, but again, CSS3 is not an official standard yet. Therefore, VS 2005 CSS validation flags color names as non-standard attributes. Remember, even if browser renders page correctly, it does not mean page will pass W3C validation. Browsers are very forgiving since they must be able to handle all kinds of HTML including pages written long before Web standards were established.

You can switch HTML validation schema to IE6 and this will allow all color names. However, both CSS and HTML validation will be agains IE6, not against XHTML.