I know that browsers strip out extra spaces after a single space. I generally use “ ” to include a second space between sentences in my HTML.
Anyway, I’m using ASP.NET MVC 3 and am trying to display an error message that’s being injected into the page via a view model (as opposed to being coded directly into the HTML template). When I add “ ” to the error string that I’m putting into the view model, I end up getting “ ” in the resulting web page, I assume because MVC 3 HTML encodes the final rendering of the view.
Anyone know a way to get around this so that I can get back my beloved double spacing between sentences? 🙂
Thanks!
Use
Html.Raw()in the view or change your view model from astringanHtmlString. Either way will bypass the HTML encoding. As long as you are sure this will be a “safe” string to render, it should be fine.