Advertisement
Advertisement


Add a linebreak in an HTML text area


Question

How can i add a line break to the text area in a html page? i use VB.net for server side coding.

2019/10/16
1
33
10/16/2019 6:58:22 AM

Accepted Answer

If it's not vb you can use 
 (ascii codes for cr,lf)

2010/06/30
53
6/30/2010 12:50:51 PM


You could use \r\n, or System.Environment.NewLine.

2008/09/15

If you're inserting text from a database or such (which one usually do), convert all "<br />"'s to &vbCrLf. Works great for me :)

2010/01/20

In a text area, as in the form input, then just a normal line break will work:

<textarea>
This is a text area
line breaks are automatic
</textarea>

If you're talking about normal text on the page, the <br /> (or just <br> if using plain 'ole HTML4) is a line break.

However, I'd say that you often don't actually want a line break. Usually, your text is seperated into paragraphs:

<p>
  This is some text
</p>
<p>
  This is some more
</p>

Which is much better because it gives a clue as to how your text is structured to machines that read it. Machines that read it include screen readers for the partially sighted or blind, seperating text into paragraphs gives it a chance of being presented correctly to these users.

2008/09/15

I believe this will work:

TextArea.Text = "Line 1" & vbCrLf & "Line 2"

System.Environment.NewLine could be used in place of vbCrLf if you wanted to be a little less VB6 about it.

2008/09/15

Escape sequences like "\n" work fine ! even with text area! I passed a java string with the "\n" to a html textarea and it worked fine as it works on consoles for java!

2017/05/14

Source: https://stackoverflow.com/questions/66773
Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Email: [email protected]