Html – Visual Studio 2008 HTML formatting – does it ever work


It's another Visual Studio 2008 HTML formatting question…I think I have either found a bug in the infamously bad VS HTML formatting, or I'm doing something wrong. Here's what I'm doing:

I remove all client side tags via:
Tools -> Options -> Text Editor -> HTML -> Format -> Tag Specific options

I then add b and span tags:

alt text

I press CTRL+E,CTRL+D and I get these two differing results:


alt text
The P before the span tag isn't formatted properly


alt text
The P tag is formatted correctly.

This for a .ASPX extension file.

Best Solution

It looks like it is a bug, and isn't dependent on the tag being SPAN or B.

The work around I found

Add an extra space before the closing P.

How it fails

<p><b>My title</b></p>

Gets re-formatted as

  <b>My title</b></p>

How to get it to work

<p><b>My title</b> </p>

(NB the space after the B) gets reformatted as:

  <b>My title</b>

And that extra space is removed by VS anyway. Hallelujah my HTML looks beautiful!