Some time ago I described how to add custom HTML markup intellisense and validation schema to VS 2005 and Visual Web Developer Express. Same steps apply to VS 2008. Here I am going to describe how to add custom CSS intellisense schema.

First of all, you can simply modify existing schema. For example, technically CSS 2.x only defines 16 color names while all modern browsers recognize many more. You can borrow color definitions from IE6 CSS schema and include then in CSS 2.1 schema. See my previous blog post for details. If you want to define completely different CSS schema, here are step by step instructions:

1. Copy existing schema file to use it as a template. CSS schemas are in Program files\Microsoft Visual Studio 9.0\Common7\Packages\1033\schemas\CSS (1033 is for English version, substiture number is you are using localized build). For example, copy CSS21.xml to MyCSS.xml.

2. Open MyCSS.xml and edit it to create desired schema. Note that schema folder contains CSS.XSD file which is XML schema for the CSS schema file.

3.  Open RegEdit go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Packages\{A764E895-518D-11d2-9A89-00C04F79EFC3}\Schemas. Typically there are 4 entries there, named Schema 1, Schema 2, etc. 

4. Create a new entry that immediately follow the last one. Do not leave any holes in the numbering sequence. For example, if you see Schema 4 as last entry, create Schema 5.

5. Under the new key create File REG_SZ value and specify MyCSS.xml

6. Create Friendly Name REG_SZ value and specify name for the schema. This name will appear in the schema dropdowns in the CSS editor toolbar.

You are done. Restart IDE, open CSS file and your new schema should appear in the dropdown. If schema does not load, most probably is does not validate against css.xsd.