Is it possible to change CSS Validation scheme in VS2010 - css

I'm editing a simple CSS file in VS2010 and the editor seems to have a rather limited understanding of CSS, for example:
#my-rule {
position:relative;
}
generates a warning: Validation(CSS 1.0): 'position' is not a known CSS property name
I'm guessing that there is an option some where to change the CSS validation to CSS 2.1 or some thing close, but can't for the life of me find it.

If you want to validate for CSS 3.0 in Visual Studio 2010, you need to install the Visual Studio 2010 Service Pack 1 and then install the "CSS 3 Intellisense Schema"
http://visualstudiogallery.msdn.microsoft.com/7211bcac-091b-4a32-be2d-e797be0db210/view/Discussions
Then you will see "CSS 3.0" in the drop down that easwee mentioned.

You have a dropdown in the top menu where you can switch the css validation. It's called Cascading stylesheet version for validation. If you can't see it right click on the menu and check Style sheet so it will show.

Related

Is there support for validating (intellisense) inline CSS3 in Visual Studio?

I am running Visual Studio 2010. I have installed SP1 and the Web Standards Update and restarted Visual Studio. I can now select CSS3 for validation and Intellisense of CSS files, but for "style" attributes of html elements, it is still using CSS 2.1. For example, the following html:
<div style="text-overflow:ellipsis;">
Some text
</div>
produces the following warning:
Validation (CSS 2.1): 'text-overflow' is not a known CSS property name
Things that I have tried that didn't work:
Adding the CSS toolbar didn't help, because when viewing an .aspx page, the options are all greyed out
The Options -> Text Editor -> CSS menu has no level options
The Options -> Text Editor -> HTML menu has no CSS level options
Changing the HTML target schema to HTML5 does not change the CSS level
Installing CSS3 IS 2.1.1 didn't change anything
Is there any way to get Visual Studio to use CSS3 for the style attributes of HTML elements?
Tools -> Extension manager
Then search for Css 3 (online gallery), install.
I'm not sure this will work, but its worth a try.

VS 2008 is auto changing my CSS file

I just migrated an web app from vs 2005 to vs 2008. I use a CSS file with styles for my buttons. In Vs2005, if I assign a style and elect to change it, I would get an inline style for that button, thus creating an exception to my style. In 2008 (also tried this in 2010) it will change the width setting in my CSS file if I resize a button... thus making a global change.
Is there a way to turn this off? I have looked most everywhere and do not see this issue on the web.
thanks
You can use in VS 2010 Skin and Theme to apply formatting to your Button. There is also a SkinId property which allow you to set a specific Style for a Web Control with that the same Id. Have a look at MS reference here http://msdn.microsoft.com/en-us/library/ykzx33wh.aspx

How do you enable error detection for CSS files in Visual Studio 2010?

How do you enable error dectection for CSS files in Visual Studio 2010? It's said to be in tools options, but I can't seem to find it.
In Visual Studio, open the Tools menu and select Options
Expand the Text Editor group, then the CSS group.
Click on Miscellaneous and you'll see the option to enable Detect Errors there.
Make sure in Visual Studio 2010 IDE> View>Toolbars>Stylesheet is checked to show Stylesheet toolbar.
IDE will indicate errors in two ways.
01) most importantly don't forget VS Error List window.It will show css errors in warnings section.you can then navigate to error by double clicking the error itself through the window.
02) it will show squiglies in erroneous CSS styles
Not sure if this is what you're asking for, but Visual Studio comes with a few CSS validation templates. If you select from the top menu View > Toolbars > Style Sheet, you'll see a little dropdown in the top toolbar. My VS 2010 lets me choose "Internet Explorer 6.0, CSS 1.0, CSS 2.0 and CSS 2.1"
If you write a property that's not valid for the currently selected CSS version, Visual Studio will put a little green line underneath it and complain about it not being a known CSS property etc.
This happened to me and CTRL+K+D gave me that same error even when detection was on. The solution was to look in the 'Errors' tab in Studio and to look at just the warnings. Scroll down to the CSS file related issues and low and behold your syntax error will be listed there.
Mine turned out to be two semi-colons ';;'
Hope this helps anyone else :)

How to suppress specific CSS 2.0 validation errors in Visual Studio 2008?

A typical CSS property that I use often is overflow-x or overflow-y. Sometimes I use CSS 2.1 or later properties or selectors. These (correctly) raise a validation error:
Validation (CSS 2.0): 'overflow-y' is not a known CSS property name.
For years I ignored this, but it kinda feels wrong. It's possible to switch off warnings in C# and other languages for a particular line, block, file or project. Is something similar possible for CSS (or HTML) errors or warnings? Instead of switching it all off, I prefer a more granular solution.
If you're willing to muck around a bit you can get exactly what you want.
Go to Visual Studio folder \Common7\Packages\1033\schemas\CSS
Copy css21.xml to css21mod.xml
Find the section:
<cssmd:property-def _locID="overflow" ...
After that section, insert:
<cssmd:property-def
_locID="overflow-x" _locAttrData="description,syntax"
type="enum"
description="Visibility of content extending beyond element's dimensions in x"
syntax="One of the overflow values | inherit"
enum="inherit auto hidden scroll visible"/>
<cssmd:property-def
_locID="overflow-y" _locAttrData="description,syntax" type="enum"
description="Visibility of content extending beyond element's dimensions in y"
syntax="One of the overflow values | inherit"
enum="inherit auto hidden scroll visible"/>
Open regedit, go to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\9.0\Packages\{A764E895-518D-11d2-9A89-00C04F79EFC3}\Schemas
If on 64-bit, you will have to go to SOFTWARE\Wow6432Node\Microsoft etc
Create a new key called Schema 5, and fill in the "File" and "Friendly Name" string values with css21mod.xml and CSS 2.1 (mod)
Should be all set!
Hi I just discovered this. In Visual Studio 2010 SP1 there is support for HTML5 validation.
Tools -> Options -> Text Editor -> HTML -> Validation
Now personally because I hate VS telling me I have duplicate ID's(Which is fine for non server controls) I turn off all warnings and set my validation to XHTML5 (Which is an option).
You can however tweak the settings till your hearts content. Sadly this is not project specific and other team members will need to do the same.
How to make Visual Studio stop "compiling" .js and .css files
Similarly as Jeremy Child suggested, but specific for Visual studio 2008 (as specified in the opriginal question):
Tools -> Options -> Text Editor -> CSS -> CSS Specific : uncheck
"Detect unknown properties"
This removes all CSS validation. This is a good solution if you need the problem to disappear fast (I have no time/bit lazy to manually add each property in an xml file and check the windows registry...) and if you are good in CSS (validation not really needed when you use built-in intellisense or styles that you are sure work -e.g. taken from previous websites you did-).
Get support for CSS 3.0 in order to suppress some of the warnings:
how to make visualstudio 2008 support css v3 & html v5
CSS 3 Intellisense Schema
So this is what happened to me. I had a successfully working project. I made a copy and started working on some label changes. And I started getting
"Validation (CSS 2.0): 'overflow-y' is not a known CSS property name."
The above error kept appearing even after reopening the projects.
So I went back to my original project, opened, started debugging to see if I get that error in that project also. The project successfully. Stopped there. Came to my new error throwing project, and now the error is no longer there.
Something to think about what caused it go away. Something in a memory. May be

How do I get rid of the unknown property name errors in Visual Studio?

When using jQuery UI and ThemeRoller the CSS files created contain several CSS properties that are not known by Visual Studio, such as zoom and opacity. How can I keep these from showing up as errors in the error list when the CSS file is open in the editor pane?
In the spirit of SO, I'll add the solution I found as a response.
Go to Tools --> Options --> Text Editor --> CSS --> CSS Specific (or Validation) and uncheck the Detect unknown properties checkbox.

Resources