How do I make a line feed in a div tag?


Tags: css,asp.net-mvc-2,html,linefeed

Problem :

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","&lt;br /&gt;") and Replace("\n","&lt;p&gt;&lt;/p&gt;"). 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;      
}


Solution :

Use:

<%= newsItem.Text %>

Instead of:

<%: newsItem.Text %>

The second method implicitly HTML encodes the string.


    CSS Howto..

    How can I set the main theme-font dynamically, in WordPress

    how to use css to style a descendant (not a direct child) of an element?

    how to apply CSS for @Html.DisplayFor?

    How to hide DIV when scroll reach at Bottom through CSS?

    HTML code to show splitted data_frame in one html page using python

    How to equally align two vertical columns created using a loop, an array, and appending childs in JavaScript (or CSS)?

    How can I align my adsense graphics?

    JavaScript/CSS: How to resize (scale) window content

    Android Crosswalk Project: How to use css?

    How to make to div comes the one under the other

    How to create grid position elements like in this image css

    How can i use css frameworks without cluttering html with too many classes [closed]

    How do I create a 'linklist' like a tooltip with HTML and CSS or jQuery and CSS?

    how come the position static on my element doesnt position relative to the parent div?

    How to add labels for multiple textboxes inside 1 li element

    How to scroll an html element both horizontally and vertically with top and side labels scrolling correctly

    css, how to stop an element being squashed by container

    How to set background color with opacity by css?

    How to build simple image rotation effect like this one in exapmle?

    jQuery Slideshow in Chrome, Firefox, and Safari

    How to debug HTML/CSS for iPhone/iPad performance?

    how to override font-color dynamically with css color property

    How to vertically center text with CSS?

    How bad is to store all background images in CSS?

    how is possible to change not nested elements attribute with css?

    How to make a ghost element in CSS?

    how to middle vertical-align using bootstrap input-group

    How to actually center (vertical and horizontal) text inside a nested div

    how to interactively toggle CSS sheets(s) on a webpage for testing/learning purposes?

    How to align/move Vaadin buttons