When writing in HTML, the <textarea> tag is an inline element used to designate a plain-text editing control containing multiple lines. It is useful for creating a form field for visitors to leave comments or messages. The following sections contain information about this tag, including an example of it in use, as well as related attributes and browser compatibility.
Tip: The width and height of a text area may be adjusted with CCS.
Example textarea code
<textarea rows="4" cols="30" placeholder="Type here..."></textarea>
Tip: The textarea tag can be addeded to an HTML form tag to allow the submitted text to be processed by a script.
Example textarea result
Within an HTML tag, an attribute dictates certain aspects of an HTML element. Attributes are made up of a name and value pair; all tags support standard attributes. The following table shows all of the current unique HTML attributes for the <textarea> tag, as well as a description of each.
|autofocus||Designates that the text area should be selected upon page loading|
|cols||Designates the visible width of a text area|
|disabled||Designates that a text area should be disabled|
|form||Designates the form(s) to which a text area belongs|
|maxlength||Designates the total number of characters allowed in the text area|
|name||Designates a name for the text area|
|placeholder||Designates a hint that describes what type of input is expected in a text area|
|readonly||Designates that a text area should be read-only|
|required||Designates that the text area must be filled out|
|rows||Designates the height of a text area|
|wrap||Designates how the text in a text area is to be wrapped upon submission|
|All versions||All versions||All versions||All versions||All versions|