Latest web development tutorials

HTML <textarea> tag

Examples

An HTML text area:

<textarea rows="10" cols="30">
我是一个文本框。
</textarea>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support <textarea> tag.


Tag definitions and instructions

<Textarea> tag defines a multi-line text input control.

Text area can hold an unlimited amount of text, the default font in which the text is monospaced font (usually Courier).

It can be predetermined by the size of textarea cols and rows attributes, but a better approach is to use the CSS height and width attributes.


Differences between HTML 4.01 and HTML5

HTML5 adds some new properties.


Attributes

New: HTML5 new property.

属性 描述
autofocus New autofocus 规定当页面加载时,文本区域自动获得焦点。
cols number 规定文本区域内可见的列数。
disabled disabled 规定禁用文本区域。
form New form_id 定义文本区域所属的一个或多个表单。
maxlength New number 规定文本区域允许的最大字符数。
name text 规定文本区域的名称。
placeholder New text 规定一个简短的提示,描述文本区域期望的输入值。
readonly readonly 规定文本区域为只读。
required New required 规定文本区域是必需的/必填的。
rows number 规定文本区域内可见的行数。
wrap New hard
soft
规定当提交表单时,文本区域中的文本应该怎样换行。


Global Properties

<textarea> tag supports HTML global properties .


Event Properties

<textarea> tag supports HTML event properties .


related articles

HTML DOM Reference: Textarea objects