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?
如何使输入更像一个文本区?
6 个解决方案
#1
509
You need to use a textarea to get multiline handling.
您需要使用一个textarea来获得多行处理。
<textarea name="Text1" cols="40" rows="5"></textarea>
#2
50
It is possible to make a text-input multi-line by giving it the word-break: break-word;
attribute. (Only tested this in Chrome)
有可能通过给它一个单词break来做一个文本输入的多行:break-word;属性。(只在Chrome中测试过)
#3
41
You can't. The only HTML form element that's designed to be multi-line is <textarea>
.
你不能。设计为多行的唯一HTML表单元素是
#4
35
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.
在打开和结束标签之间不要留下任何空格,否则会留下一些空的行或空格。
#5
12
Check this:
检查:
- http://www.w3.org/TR/html401/interact/forms.html#h-17.7
- http://www.w3.org/TR/html401/interact/forms.html h - 17.7
The TEXTAREA element creates a multi-line text input control
TEXTAREA元素创建一个多行文本输入控件。
#6
0
You should use textarea
to support multiple-line inputs.
您应该使用textarea来支持多行输入。
<textarea rows="4" cols="50">
Here you can write some text to display in the textarea as the default text
</textarea>
#1
509
You need to use a textarea to get multiline handling.
您需要使用一个textarea来获得多行处理。
<textarea name="Text1" cols="40" rows="5"></textarea>
#2
50
It is possible to make a text-input multi-line by giving it the word-break: break-word;
attribute. (Only tested this in Chrome)
有可能通过给它一个单词break来做一个文本输入的多行:break-word;属性。(只在Chrome中测试过)
#3
41
You can't. The only HTML form element that's designed to be multi-line is <textarea>
.
你不能。设计为多行的唯一HTML表单元素是
#4
35
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.
在打开和结束标签之间不要留下任何空格,否则会留下一些空的行或空格。
#5
12
Check this:
检查:
- http://www.w3.org/TR/html401/interact/forms.html#h-17.7
- http://www.w3.org/TR/html401/interact/forms.html h - 17.7
The TEXTAREA element creates a multi-line text input control
TEXTAREA元素创建一个多行文本输入控件。
#6
0
You should use textarea
to support multiple-line inputs.
您应该使用textarea来支持多行输入。
<textarea rows="4" cols="50">
Here you can write some text to display in the textarea as the default text
</textarea>