Reputation: 95
Visual Studio 2013 (Update 4) in MVC 5: The code editor (in HTML mode) inserts a space between spans when they are on separate lines. This occurs even when the spans are initially on one line with no intervening space and then forced onto two lines in the code editor (either because of their length when reformatted, or simply by placing the cursor between them and hitting enter). This occurs regardless of the four possible combinations of block v. smart tabs and tabs v. spaces.
This code:
<span id="someid">text</span><span id="someotherid">, optional text</span>
<span id="newsomeid">, even more text</span>
<span id="newsomeotherid">, some more optional text</span>
yields this text in IE 11, Firefox, Chrome, and Opera:
"text, optional text , even more text , some more optional text"
Note the spaces after the second and third "text". Other than making sure that the code remains on one line, and therefore not reformatting, is there a way to remediate this problem?
Thanks for any help.
Upvotes: 0
Views: 453
Reputation: 93484
This is not a visual studio problem, or an mvc problem. This would happen with standard HTML in a text file in internet explorer.
The fact of the matter is, you DO have whitespace between your spans... it's a newline character. the HTML renderer treats all whitespace as a single "space" including tabs, newlines, etc.. This is only really a problem though because you are separating two elements by whitespace, which creates a new text element in the rendering tree (which you can see by viewing it in developer tools).
This is "by design", and your only solution is to put the span elements next to each other without any intervening whitespace, including line breaks.
Upvotes: 3