Anatoly Lubarsky Logo
programming, design, integration, games, music

VS 2005: HTML validation checking

A couple of days ago Scott Guthrie posted about HTML validation checking feature in Visual Studio 2005:


"...The reason we are now surfacing HTML validation issues in the error list by default is that we are trying to promote more standards-based HTML with VS 2005 and ASP.NET 2.0, as well as to catch potential rendering and browser functionality errors earlier in the development process (so that you dont have to run and carefully analyze every page in your app. looking for these types of issues).

...If youd rather not have these types of HTML validation errors show up in your error-list, you can disable this functionality by selecting the Tools->Options menu item in VS or Visual Web Developer."


The fact is that many developers are unhappy about this feature. For example Rick Strahl explains several issues regarding HTML validation:


"...So there are two issues here: First the fact that HTML format errors really have no business being flagged as errors. Errors in this environment should only be things that break the build and HTML errors don't qualify in my book. I can appreciate the folks who are Nazis about their HTML Validation and want to see them prominently, but having them show as errors doesn't do anything other than display here its not breaking the build, so this is purely an annoying and non-configurable GUI feature."

...The other is that of context. If I compile an individual assembly, that has nothing to do with HTML markup tags why should the IDE show these errors in this place its completely out of context. Theres no options to have VS show the difference between background compile/eval errors of whats open and what compile you just ran. All this stuff just gets jumbled together into a single bin."


I agree. Half a year ago I posted a bug on compiler errors in xhtml about inconsistent behavior and conversion issues. It was resolved by design:


"Thank you for your feedback. After Beta 2, we changed XHTML conformance to Transitional for all new Whidbey applications. Unfortunately, this triggers an issue when converting a VS03 web project. A number of developers wrote script that relied on the id attribute of the Form tag (it was the most common breaking change for ASP.NET in compatibility labs around the worlds) . This is a not allowed attribute in transitional -- so if we make it transitional on upgrade scenarios we break a lot of developer client side script. So when we convert a VS03 web project we set XHTML conformance to use Legacy mode."


What do you think ?


Related Posts:

Saturday, November 26, 2005 5:57 PM

Comments

# re: VS 2005: HTML validation checking
One of the facts of life with web development today is that we live in a multi-browser world and building good web UI that works seamlessly with all browsers isn't easy.

One of the big pain-points is the fact that a lot of things often "kinda work", but ultimately perform or render in subtle different ways in different browsers (small spacing differences, rendering issues, etc). Keeping track of "standards mode", "quirks mode", and "transitional" renderings is a real pain and time-sync (and trying to keep everyone on a team up-to-date with them is not easy). I would personally prefer chasing down a deadlock bug over a subtle Opera/IE/FireFox/Safari overlay spacing issue any day of the week.

The goal with adding the HTML validation features into VS 2005 was to help make it easier for developers to know exactly what is -- and what isn't -- legal html/css to add to their app, and to help developers write code that has the best possible chance of working consistently in all browsers the first time around (specifically by writing to agreed on standards supported by all systems).

It can ceretainly be a "pain" when you see a lot of errors show up in the error-list indicating that there are problems with your HTML. But I would argue that it is *a heck of a lot* more of a pain trying to identify and fix rendering problems in multiple browsers on multiple operating systems once the app is built and deployed (especially since the bug reports you'll receive from users tend to be hard to pinpoint comments like "it looks really bad and I don't like it"). Rather than force people to manually learn/verify what is/isn't legal, we wanted VS 2005 to help automate the verification and guide new markup to be correct.

The reason we chose to mark html validation issues as errors as opposed to warnings is because if a user using a non-IE browser is trying to access your web app and it doesn't render or work correctly for them, then they are going to interpret/believe the app is buggy. I do agree with Rick's feedback that there should be a better way to filter these errors in the error list (maybe adding another tab to enable easily turning them on and off -- something I think we should do for the next release). But I do think we need to help educate and guide developers towards writing web apps that will work in all browsers -- and to treat things that prevent this from working as "errors/bugs", instead of just "warnings/nice to-dos".

One thing to call out (for those that haven't used the feature yet), is that the HTML validation support can actually be configured to validate different things for different standards and at different levels. The default validation we use out of the box with a clean VS 2005 install is "XHTML Transitional", but can be configured to be "XHTML Strict", "HTML 4.01" or even "IE 6.0" instead. This later option is the closest approximation to the HTML generated by VS 2003, and is a setting you might want to use if you have a large amount of HTML that is non-legal but you aren't ready yet to invest the time to fix it to be more standards compliant and/or non-IE browser compatible. Switching between the different validation standards is pretty easy (by default there is a drop-down box in your toolbar to allow you to switch target schemas rapidly and on the fly).

For example, the errors in Rick's post with the colors are because the page is being validated using an XHTML Transitional validation setting, but it is using non-standard color names that might not work in all browsers and are not XHTML legal (here is the list of legal HTMl 4 and XHTML colors: http://www.webstandards.org/learn/reference/color_names.html). If he changed the validation to instead be "IE 6.0" -- then those specific validation errors will go away.

By default, when you upgrade an existing VS 2003 web project, we actually set the validation to be "IE 6.0" to help minimize the errors you see (note: this was a late RTM fix -- so wasn't what happened in Beta2). For HTML 4.01 and IE 6.0, there are also sub-levels of validation that you can set if you want to incrementally add additional validation rules (for example: you can choose to validate inside css style elements or not, validate element casing, element close tags, etc).

If you don't want or care about HTML validation at all, you can also obviously turn it off completely. This blog post shows how: http://weblogs.asp.net/scottgu/archive/2005/11/23/431350.aspx.

Hope this helps,

Scott

11/27/2005 10:19 PM by scottgu@microsoft.com

# re: VS 2005: HTML validation checking
thanks, Scott
I really appreciate it

11/27/2005 11:16 PM by Anatoly Lubarsky

# re: VS 2005: HTML validation checking
Any particular reason why there's no option to set the validation type to something like "Automatic" and have VS check for a DOCTYPE declaration in order to determine the rules to use?

12/4/2007 2:04 PM by Rich

Login

Subscribe via RSS

Article Categories

.Net Framework
ASP.NET Tips
C# Win32 API
HTML, CSS, Web
Javascript Tips
MSSQL Tips
System
System.Net
WebServices

Archives

(02) January 2018
(01) June 2013
(03) March 2013
(02) February 2013
(01) July 2012
(01) April 2012
(01) September 2011
(01) August 2011
(03) May 2011
(01) December 2010
(01) November 2010
(01) October 2010
(01) June 2010
(01) May 2010
(02) March 2010
(01) January 2010
(02) December 2009
(03) September 2009
(03) August 2009
(09) July 2009
(04) June 2009
(03) May 2009
(02) April 2009
(03) March 2009
(02) February 2009
(02) January 2009
(04) December 2008
(04) November 2008
(05) October 2008
(04) September 2008
(05) August 2008
(04) July 2008
(05) June 2008
(07) May 2008
(04) April 2008
(03) March 2008
(02) February 2008
(03) January 2008
(03) December 2007
(05) November 2007
(04) October 2007
(05) September 2007
(12) August 2007
(11) July 2007
(14) June 2007
(13) May 2007
(13) April 2007
(10) March 2007
(11) February 2007
(14) January 2007
(14) December 2006
(12) November 2006
(08) October 2006
(09) September 2006
(06) August 2006
(08) July 2006
(10) June 2006
(09) May 2006
(22) April 2006
(25) March 2006
(12) February 2006
(14) January 2006
(19) December 2005
(17) November 2005
(16) October 2005
(16) September 2005
(12) August 2005
(14) July 2005
(09) June 2005
(12) May 2005
(12) April 2005
(20) March 2005
(11) February 2005
(12) January 2005
(18) December 2004
(13) November 2004
(12) October 2004
(14) September 2004
(09) August 2004
(23) July 2004
(19) June 2004
(29) May 2004
(19) April 2004
(16) March 2004
(09) February 2004
(06) January 2004
(02) December 2003
(01) November 2003

Post Categories

.Net and C#
Android
Antispam
App. Development
Architecture
ASP.NET
Blogging
Deprecated Projects
Facebook Platform
Fun
Google
iOS
Javascript
Misc.
MSSQL
Music
My Games
Performance
Roller
Social Networks
Tools
Visual Studio
Web 2.0
WebServices

About Me

linkedin Profile
Recs
Who am I

My Sites

Billy Beet
x2line blogs