<textarea>
文本区中可容纳无限数量的文本,其中的文本的默认字体是等宽字体(通常是 Courier)。
可以通过 cols 和 rows 属性来规定 textarea 的尺寸,不过更好的办法是使用 CSS 的 height 和 width 属性。
注释:在文本输入区内的文本行间,用 "%OD%OA" (回车/换行)进行分隔。
最常用的属性是cols和rows,用来规定textarea的尺寸。另外,还有其他一些属性如下:
属性
|
值
|
描述
|
4
|
5
|
---|---|---|---|---|
autofocus
|
true
false
|
在页面加载时,使这个 textarea 获得焦点。
|
5
| |
cols
|
number
|
规定文本区内可见的列数。
|
4
|
5
|
disabled
|
true
false
|
当此文本区首次加载时禁用此文本区。
|
4
|
5
|
form
|
true
false
|
定义该 textarea 所属的一个或多个表单。
|
5
| |
inputmode
|
inputmode
|
定义该 textarea 所期望的输入类型。
|
5
| |
name
|
name_of_textarea
|
为此文本区规定的一个名称。
|
4
|
5
|
readonly
|
true
false
|
指示用户无法修改文本区内的内容。
|
4
|
5
|
required
|
true
false
|
定义为了提交该表单,该 textarea 的值是否是必需的。
|
5
| |
rows
|
number
|
规定文本区内可见的行数。
|
4
|
5
|
描述
Common -- 一般属性
cols -- 多行输入域的列数
rows -- 多行输入域的行数
accesskey -- 表单的快捷键访问方式
disabled -- 输入域无法获得焦点,无法选择,以灰色显示,在
表单中不起任何作用
readonly -- 输入域可以选择,但是无法修改
tabindex -- 输入域,使用"tab"键的遍历顺序
示例
<html>
<body>
<form action="../dreamdu.php" method="post" id="dreamduform">
<label for="contactus">请联系我们</label>
<textarea cols="50" rows="10" id="contactus" name="contactus">
可爱的猴子 </textarea>
</form>
</body>
</html>
参考:
http://www.w3school.com.cn/tags/tag_textarea.asp