stkvtflw stkvtflw - 2 months ago 20
HTML Question

Line break in html with `\n`

I feel like i'm asking very noob question) Is there way to make html properly treat

\n
line breaks? Or i have to replace them with
<br/>
?

https://jsfiddle.net/zawyatzt/

Answer

This is to show new line and return carriage in html, then you don't need to do it explicitly. You can do it in css by setting the white-space attribute pre-line value.

<span style="white-space: pre-line">@Model.CommentText</span>