html教程

定义和用法

定义一个文本区域 (text-area) (一个多行的文本输入区域)。用户可在此文本区域中写文本。在一个文本区中,您可输入无限数量的文本。文本区中的默认字体是等宽字体 (fixed pitch)。

 

HTML 4.01 与 HTML 5 之间的差异

HTML 5 中有一些新属性,同时不再支持 HTML 4.01 中的一些属性。

 

例子

<textarea rows="3" cols="30"> 
这里是文本域中的文本 ... ... ... ... 
</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

 

标准属性

class, contenteditable, contextmenu, dir, draggable, id, irrelevant, lang, ref, registrationmark,

tabindex, template, title

如需完整的描述,请访问 HTML 5 中标准属性。


事件属性

onabort, onbeforeunload, onblur, onchange, onclick, oncontextmenu, ondblclick, ondrag, ondragend,

ondragenter, ondragleave, ondragover, ondragstart, ondrop, onerror, onfocus, onkeydown, onkeypress,

onkeyup, onload, onmessage, onmousedown, onmousemove, onmouseover, onmouseout, onmouseup,

onmousewheel, onresize, onscroll, onselect, onsubmit, onunload

如需完整的描述,请访问 HTML 5 中事件属性。

 

TIY 实例

Textarea,如何创建 textarea。

<html> 
<body> 
<p> 
This example cannot be edited 
because our editor uses a textarea 
for input, 
and your browser does not allow 
a textarea inside a textarea. 
</p> 
<textarea rows="10" cols="30"> 
The cat was playing in the garden.