Is there any way to get Visual Studio 2010 to properly format HTML code when reformatting?
In HTML,
<div><span></span></div>
is different than
<div> <span></span> </div>
because of the space after the <div>
.
Once there is a space, it doesn't matter how many spaces or line breaks there are... so
<div> <span></span> </div>
is the same as
<div>
<span></span>
</div>
However, the editor is quite happy to insert or remove spaces/linebreaks between tags. For most cases, that won't matter much, but in some cases, it is critical to control whether there is whitespace between tags.
Similarly, I may want to have <span> </span>
with space between the tags, but the editor removes that space!
Is there any solution to this?
Use
if you want to make sure that space is conserved. Browsers may optimize out empty divs for example (see this question), and containing only whitespace is considered being empty.