Adding CSS Colors to Visual Studio 2005

By | January 5, 2008

One of my biggest pet peeves about Visual Studio (and there’s a few), is that it displays a lot of HTML formatting errors as errors, instead of warnings in the Error List.

One of the most common HTML errors that Visual Studio 2005 will list for me is the color value, such as “AliceBlue“, “Bisque“, “CornflowerBlue“, “Chartreuse” and “Linen” to name a few.

The reason why Visual Studio only accepts a small number of valid colours (16 or 17), is because they are considered “W3C Standard Color Names” (aqua, black, blue, fuchsia, gray, green, lime, maroon, navy, olive, purple, red, silver, teal, white, yellow and sometimes orange).

The first set of colours that I mentioned (AliceBlue, Bisque, CornflowerBlue, Chartreuse and Linen), fall under the “Cross-browser Color Names” category (W3Schools).

Now, some of you may point out that “AliceBlue“, “Bisque“, “CornflowerBlue“, “Chartreuse” and “Linen” are not W3C standard colors, and therefore wouldn’t validate if it were ran through the CSS Validation Service. Well, you would be correct, but gosh darn it, if I want to use CornflowerBlue as my background-color, especially when it works in IE, Opera and Firefox, even when my DocType is set to strict, I should be allowed to, without having someone or something complaining about it all of the time.

So, if you’re like me, and are fed up with these warnings, you’ll be happy to know that there the solution to your problems can be found in C:\Program Files\Microsoft Visual Studio 8\Common7\Packages\1033\schemas\CSS. In this folder you will find the following files: css10.xml (CSS 1.0), css20.xml (CSS 2.0), css21.xml (CSS 2.1) and css-ie60.xml (Internet Explorer 6.0). Each of these files contains the W3C’s valid CSS properties and values.

Before modifying any of the files, you should first make a backup copy.

If you wish to make Visual Studio ignore your special colour names, the default file that Visual Studio uses is css20.xml.

For those of you who may think that adding additional colours to the list of CSS valid colours is somehow morally incorrect, you’ll be happy to know that there is another way. Go to Tools > Options then expand Text Editor and then HTML and click on Validation.

Here you will see Target, with a drop down list. If you want, you can change the value to Internet Explorer 6.0 (which I think is a bigger no-no).

One thought on “Adding CSS Colors to Visual Studio 2005

  1. Pingback: DotNetKicks.com

Leave a Reply

Your email address will not be published. Required fields are marked *