I have a text that have som \n
in it.
But when showing the text in a div there are no line feeds.
How do I make a line feed in a div???
I have tried to Replace("\n","<br />")
and Replace("\n","<p></p>")
.
But the <br /> is showed instead of a line feed.
ASP.NET:
<div class="text"> <%: newsItem.Text %></div>
CSS:
.text
{
color: Black;
margin-top: 10px;
margin-bottom: 10px;
}
Use:
<%= newsItem.Text %>
Instead of:
<%: newsItem.Text %>
The second method implicitly HTML encodes the string.