<textarea> tag
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, and related attributes and browser compatibility.
The width and height of a text area may be adjusted with CCS (common command set).
Example textarea code
<textarea rows="4" cols="30" name="example" placeholder="Type here..."></textarea>
The textarea tag can be added to an HTML form tag to allow the submitted text to be processed by a script.
Example textarea result
Textarea attributes
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, and a description of each.
Attribute | Description |
---|---|
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) 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. |
Textarea compatibility
Internet Explorer | Firefox | Safari | Opera | Chrome |
---|---|---|---|---|
All versions | All versions | All versions | All versions | All versions |
Browser, Compatibility, Container tag, Plaintext, Text, Textbox, Web design terms