0

I have textarea with defaultvalue like this:

<textarea>
  One Two Three
</textarea>

How can i display field like this:

One
Two
Three
Neo
  • 151
  • 1
  • 1
  • 7

3 Answers3

2

Assuming you're referring to the placeholder, this has been answered on here: Insert line break inside placeholder attribute of a textarea?

Note there's no simple way, just some hacks that may work in some browsers and not others like using &#10 where you want the line break.

<textarea placeholder="one&#10; two">
</textarea>

Depending on what you're going for you could set the width or use something like col="5" to force each word to the next line, but that also affects the user input.

416e6f6e
  • 51
  • 7
  • I want it is defaultvalue because user can delete per line when they input per field, if it is placeholder, when input all placeholder is disappear. – Neo Aug 28 '19 at 06:03
  • per line of defaultvalue is guide to input, i want user delete per line to add info for that line, other line still appear – Neo Aug 28 '19 at 06:05
  • Try this solution: https://stackoverflow.com/questions/8627902/new-line-in-text-area – 416e6f6e Aug 28 '19 at 06:19
0

My solution here

I replace space character by <br/> tag

Hao Le
  • 1
0

Solution: Break with \r\n with default text area. It will work.

"One\r\nTwo\r\nThree\r\nFour"
Thirsty Six
  • 399
  • 1
  • 6
  • 13