HTML <textarea> tag
The <textarea> tag is used to display a textarea. A textarea is a form element similar to the textbox but with more flexibility. A textarea allows more than a single line of text, and its width and height can be changed as well.
Attributes
| Attribute | Description | Possible values |
|---|---|---|
| cols | Required. Sets the number of columns in a textarea | numColumns |
| rows | Required. Sets the number of rows in a textarea | numRows |
| disabled | Sets a textarea to be disabled (will be grayed out and the user will not be able to edit it) | disabled |
| name | Sets the name of a textarea | txtareaName |
| readonly | Specifies that a textarea is read-only, meaning you can't change its content but only read what's already there | readonly |
Standard attributes
accesskey, class, dir, id, lang, style, tabindex, title, xml:lang
For more information on standard attributes, check out our HTML standard attributes reference page.
Event attributes
onblur, onchange, onclick, ondblclick, onfocus, onmousedown, onmousemove, onmouseout, onmouseover, onmouseup, onkeydown, onkeypress, onkeyup, onselect
For more information on event attributes, check out our HTML event attributes reference page.
Example
Tips & notes
Use the textarea when you want to receive data that may require a paragraph or two such as user feedback. You can use a textbox for the users name, another textbox for the users email address, and a textarea for the users feedback.
If you want some text to appear in a textarea when the page loads, include that text between the <textarea> and </textarea> tags. The above example demonstrates this concept.