Can you make newline characters \n display as breaks <br />?
Just add this white-space
css style property to render Multiline texts :
.multiline
{
white-space: pre-wrap;
}
and then :
<div class="multiline">
my
multiline
text
</div>
now newlines will render like br elements.
white-space CSS works fine but for cross-browser compatibility
.abc {
word-wrap: break-word; /* IE 5.5-7 */
white-space: pre-wrap; /* Modern browsers */
}
Your Html
<div class="abc">
Lorem
Ipsum
is
simply
dummy
</div>
MDN Source
How about HTML/CSS? If you put your text inside a <pre>
tag, it will show all newlines exactly as they were. Alternatively, you can achieve the same effect by applying the CSS style white-space:pre
to any element.
Don't forget to HTMLencode it still (<
to <
etc.), otherwise it will all break apart at the first angle bracket.