Fog Creek Software
Discussion Board

Welcome! and rules

Joel on Software

Stopping Visual Studio From Reformatting HTML

Does anyone know of a way to stop VS/2003 from automatically reformatting valid xhtml all the time?

It keeps changing line breaks, removes quotes around attributes, converts tags to upper case, and removes the trailing "/" from empty tags.  (<br /> becomes <br>)

I have going into the "text editor" section of the options and turned off everything I can see under all the parts, but VS still insists that it knows far better than I do about how one should write and format HTML.  Unfortunately, whoever was responsible for that part of the design of VS/2003 clearly had no understanding of anything that had happened in the world of web markup standards since the late 1990's.

Any suggestions?

Ken Ray
Wednesday, March 30, 2005

As far as I know, you're stuck with it until VS2005 (if you decide to go that route)

I've never had the exact problem, but I have had indention/white space changes. You can avoid those by not using design mode. Or if you do go to design mode to check something out, make sure you undo any changes VS is kind enough to make for you before you start coding up a storm.

Hope that helps

Wednesday, March 30, 2005

If you only make changes in HTML mode instead of Design mode then you can avoid most of the re-formatting. Even that approach doesn't prevent the re-formatting of elements within panels though. I guess the only way to avoid that is to eliminate panels and use tables or divs instead.

As the other poster said, this problem is the biggest complaint that everybody has with Visual Studio. Microsoft is saying that the reformatting problem will be fixed with Visual Studio 2005 and it will always produce valid XHTML.

Mike Green
Wednesday, March 30, 2005

Hey Ken

There are ways around the problem in VS 2003, but it's still a major gripe with me that you even need to in the first place. Thankfully 2005 *is* more sensible in this regard...

Here are two URLs that may help:

the second link is in German - not sure if that helps you any, but you could always try and translate it.

Good luck!

Joshua Marshall
Friday, April 01, 2005

I'm using VS 2003 and I have *finally* got it to leave my HTML alone even when I switch between design to html modes.  I'm not sure if this is exactly what you are looking for BUT they way I did it was go to Tools -> Options -> Text Editor -> HTML/XML -> Format and remove the checkbox beside every value on the dialog.

I can now switch between design and html modes and the autoformat doesn't touch my html.

Hope this helps.  Good luck.

James Smith
Tuesday, April 12, 2005

I just set up my VS.NET 2003 for coding strict XHTML code.

This file contains the important files:

Copy the xsd to C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\Packages\schemas\html.

The aspx goes to C:\Program Files\Microsoft Visual Studio .NET 2003\VC#\VC#Wizards\CSharpAddWebFormWiz\Templates\1031. (Similar for VB7, rewrite the default webform as you like.)

You still won't have strict code because of name-attribut in form-element and viewstate hidden input field.

That's why you need to modify your code on run-time with a responsefilter. Read articel and Download at

See example project at for making the responsefilter a class you can use in your projects.

You already discovered the "Apply Automatic formatting" options and the lower case settings for elements...


Thursday, April 21, 2005

*  Recent Topics

*  Fog Creek Home