开发者

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

开发者 https://www.devze.com 2022-12-19 10:25 出处:网络
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:

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.

  1. Go to Visual Studio folder \Common7\Packages\1033\schemas\CSS
  2. Copy css21.xml to css21mod.xml
  3. Find the section:

    <cssmd:property-def _locID="overflow" ...
    
  4. 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"/>
    
  5. 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

  6. 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

0

精彩评论

暂无评论...
验证码 换一张
取 消