<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
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.
Properties | Value | Description |
---|---|---|
autofocusNew | autofocus | Specifies that the text area automatically gains focus when the page loads. |
cols | number | Specifies the number of visible columns in the text area. |
disabled | disabled | Specifies that the text area is disabled. |
formNew | form_id | Define one or more forms to which the text area belongs. |
maxlengthNew | number | Specifies the maximum number of characters allowed in the text area. |
name | text | Specifies the name of the text area. |
placeholderNew | text | Specifies a short hint describing the desired text area input value. |
readonly | readonly | Specifies that the text area is read-only. |
requiredNew | required | Specifies that the text area is required/required. |
rows | number | Specifies the number of visible rows in the text area. |
wrapNew | hard 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