I have asked this question now several ways, but still have not gotten an answer.
When you capture asci text in a textarea that includes line breaks, it seems to insert invisible characters in the form of line breaks when you hit return. The line break seems to have the format \r for return or \n for new line. These characters are not visible in the text but are there somewhere.
However, when I put this code in a textarea, I cannot get it to display a linebreak. In fact, I cannot find any code that placed between textarea tags displays a line break.
Can someone show a way to display line breaks in a textarea, ie.
<textarea>first line <some code> second line </textarea>
I have really tried about everything you could possibly imagine. For example, if I try <textarea> first line "\r\n" second line</textarea>
it just displays
`firstline "\r\n"` second line
Note: anything involving <br>
will not solve this problem as this is not about html, but rather plain text displaying in textarea box.
Thanks for suggested code to display line breaks in textarea.
To preserve line breaks when getting text from a textarea with JavaScript, we can replace whitespace characters with '<br>\n' .
The <pre> tag defines preformatted text. Text in a <pre> element is displayed in a fixed-width font, and the text preserves both spaces and line breaks. The text will be displayed exactly as written in the HTML source code.
Of course, there are situations in which there is need to add line breaks. You can do so by simply hitting Shift + Return or Shift + Enter , respectively.
No, it is not possible(it will not render the UI).
Well if you're doing this through pure HTML, then you can do it one of two ways. Just add lines by pressing enter or using the ASCII characters 
 

jsFiddle
If you are using javascript you can use the textarea element value Property.
var tb = document.getElementById("tb");
var newLine = "\r\n";
var text = "Output: " + newLine + "-------------------" +
newLine + "line 1: " +
newLine + "line 2: ";
tb.value = text;
//console.log(text);
<textarea id="tb" rows=5>
Output: -------------
</textarea>
Run it on JSFiddle
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With