Tip #81: Did you know... How to Select the CSS Schema for Intellisense and CSS Properties?

In Visual Studio 2008, there is a Style Sheet Toolbar (visible only when a CSS file is active) which allows the user to select a CSS Schema, as seen in this screen shot:

 css1

However, this setting only affects the CSS editor, not the Intellisense in aspx or html files, nor the properties/values displayed in the CSS Property Grid, as shown here:

css2

Setting the CSS schema for aspx/html pages is actually a bit obscure; in VS 2008 the current CSS schema in use is deduced rather than selected, and the setting is not displayed. The CSS schema is selected to complement the HTML schema, selected via the HTML Source Editing Toolbar, as shown below:

css3

Selecting a “Target Schema for Validation” in the HTML Source Editing Toolbar implicitly selects a corresponding CSS schema, which is used in all aspx/html and similar documents opened in the web designer (documents with Design/Split/Source buttons displayed at the bottom of the window.)

Here is the table of correspondence for Visual Studio 2008:

HTML Schema CSS Schema
Internet Explorer 6.0 Internet Explorer 6.0
Internet Explorer 3.02/Netscape Navigator 3.0 CSS 1.0
Netscape Navigator 4.0 CSS 2.1*
HTML 4.01 CSS 1.0
XHTML 1.0 Transitional CSS 2.0
XHTML 1.0 Frameset CSS 2.0
XHTML 1.1 CSS 2.1

* For Netscape Navigator 4.0, no CSS schema is specified, but CSS 2.1 is used.

Hope this helps!

Van Kichline

SDET | Visual Web Developer