Advertisement
Advertisement


Multiple lines of input in


Question

I have this text input in a form:

<input type="text"
       cols="40" 
       rows="5" 
       style="width:200px; height:50px;" 
       name="Text1" 
       id="Text1" 
       value="" />

I am trying to get it to take multiple lines of input. The width and height make the box to be bigger, but the user can enter text all (s)he wants yet it fills one line only.

How do I make the input more like a textarea?

2014/05/01
1
418
5/1/2014 1:15:27 PM

Accepted Answer

You need to use a textarea to get multiline handling.

<textarea name="Text1" cols="40" rows="5"></textarea>

2016/09/01
702
9/1/2016 3:12:39 PM

It is possible to make a text-input multi-line by giving it the word-break: break-word; attribute. (Only tested this in Chrome)

2013/12/04

You can't. At the time of writing, the only HTML form element that's designed to be multi-line is <textarea>.

2020/01/08

Use the textarea

<textarea name="textarea" style="width:250px;height:150px;"></textarea>

don't leave any space between the opening and closing tags Or Else This will leave some empty lines or spaces.

2013/06/20

Check this:

The TEXTAREA element creates a multi-line text input control

2011/06/07

You should use textarea to support multiple-line inputs.

<textarea rows="4" cols="50">
Here you can write some text to display in the textarea as the default text
</textarea>
2018/04/21

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