<textarea>


HTML <textarea> Tag

Instance

<!DOCTYPE html>
<html>
<head> 
<meta charset="utf-8"> 
<title>php中文网(php.cn)</title> 
</head>
<body>

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

</body>
</html>

Run Example»

Click the "Run Instance" button to view the online instance


Browser support

1000.png

All major browsers support< textarea> tag.


Tag definition and usage instructions

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

The text area can hold an unlimited amount of text, and the default font for the text is a fixed-width font (usually Courier).

You can specify the size of the textarea through the cols and rows attributes, but a better way is to use the CSS height and width attributes.


Differences between HTML 4.01 and HTML5

HTML5 adds some new attributes.


Attributes

New: New attributes in HTML5.

PropertiesValueDescription
autofocusNew autofocus Specifies that the text area automatically gains focus when the page loads.
colsnumberSpecifies the number of visible columns in the text area.
disableddisabledSpecifies that the text area is disabled.
formNewform_id Define one or more forms to which the text area belongs.
maxlengthNewnumberSpecifies the maximum number of characters allowed in the text area.
nametextSpecifies the name of the text area.
placeholderNewtextSpecifies a short hint describing the desired text area input value.
readonlyreadonlySpecifies that the text area is read-only.
requiredNewrequiredSpecifies that the text area is required/required.
rowsnumberSpecifies the number of visible rows in the text area.
wrapNewhard
soft
Specifies how the text in the text area should wrap when the form is submitted.


Global attributes

<textarea> tag supports global attributes of HTML.


Event attributes

<textarea> tag supports HTML event attributes.


Related articles

HTML DOM Reference Manual: Textarea Object