51

I use Visual Studio as my editor for .css and .js files.. It REALLY SUCKS especially with .js files since it insists on indenting them in a very weird way, but I find it convenient that the first alt-tab is always the browser instead of another editor, and that ctrl-tab is always either the code file or the css/js.

Anyways, in all its radiant wisdom it decides to check them for syntax errors as well and every time I compile my project it gives several "errors" that push down the real errors of the compilation, so every time I make a syntax error in a code file I have to scroll down through all the js/css errors to see what's wrong.

Examples of such errors (that aren't really errors) are:

Error   7   Validation (CSS 2.1): 'text-rendering' is not a known CSS property name.
Error   8   Validation (CSS 2.1): 'opacity' is not a known CSS property name.

The situation also got much worse recently, since it now keeps parsing a .js file as a .css file for some reason, so I get errors such as:

Error   1   Unexpected character sequence. Expected a selector for the style rule.  E:\Dev\anacletus\Static\set_focus.js    2
Error   2   Unexpected character sequence. Expected a property name for the " : " declaration. E:\Dev\anacletus\Static\set_focus.js    3
Error   3   Validation (CSS 2.1): 'set-focus' is not a known CSS property name. E:\Dev\anacletus\Static\set_focus.js    3

I even deleted that particular file from the solution (it's not there anymore anywhere), but it keeps parsing it anyway.

In short, how can I disable this feature?

2 Answers 2

65

Enter the options through

Tools > Options

If it isn't checked, check the "Show all settings" box at the bottom of that window.

In the tree to the left, choose:

Text Editor > CSS > CSS Specific

Uncheck "Detect Errors". Then, choose:

Text Editor > JScript > Miscellaneous

Uncheck "Show syntax errors".

You can also change how it indents each type of code too, in the various settings in those "Text Editor" sub-options.

5
  • If you want to receive warnings as errors, and if you want to check based on CSS 3.0 level (which is possible even for VS 2010), read my answer below.
    – Matt
    Commented Aug 12, 2013 at 12:21
  • FYI: In VS2013 it seems to be Tools->Options->Text Editor->CSS->Advanced and then Validation(on the right pane)
    – Kjellski
    Commented Mar 4, 2015 at 13:35
  • 2
    In VS 2015 Update 3. It is located in Tools> Options> Text Editor> Javascript> IntelliSense> General Uncheck Show syntax errors Commented Sep 14, 2016 at 2:49
  • I needed to restart Visual Studio to get it to work. Or maybe I just needed to clear the Error List. Commented Oct 19, 2017 at 23:33
  • in VS 2017 it is Tools\Options\Text editor\JavascripTypescript\CodeValidation. (it is possible to find this option using QuickLaunch textbox in the VS window title
    – oleksa
    Commented Jun 13, 2019 at 13:19
3

I know, this question is old, but I have an update (for Visual Studio 2010):

The accepted solution has a big disadvantage: It disables all syntax checking of CSS and JScript. If you still want to have meaningful warnings, you can do the following workaround. It will treat errors as warnings, and it will do css validation on css V3.0 level rather than on (old) css V2.1:

  1. Close Visual Studio
  2. Download and install the web standards package for Visual Studio 2010 SP 1
  3. Open the path (on 32 bit machines, it is Program Files)

    C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\1033\schemas\CSS

  4. Backup CSS21.xml for safety reasons
  5. Overwrite CSS21.xml by the file CSS30.xml (in the same directory)
  6. Open Visual Studio. In Text Editor settings, (re-)enable "Show syntax errors". Ensure you have checked "as warnings" too.
From now on syntax checking of CSS is done on 3.0 level (although it appears in Visual Studio now as 2.1), and you're getting warnings instead of errors if the syntax checker finds anything.

(Note that the Style Sheet toolbar only allows to enable CSS 3.0 checking for css files, not for HTML. Hence, this fix is needed if you want to keep syntax checking)

Not the answer you're looking for? Browse other questions tagged or ask your own question.