Specifies a scrollable text box. | HTML 2, 3.2, 4, 4.01, 5 |
HTML Syntax
<textarea
autocomplete
cols = num_chars
dirname = control_name
disabled
form = form_name
maxlength = int
minlength - int
name = control_name
placeholder = label
readonly
required
rows = num_lines
wrap = off | hard | soft
>
NOTE: Both start and end tags are required.
The <textarea
> element defines a multiline text input control wherein users can enter one or more lines of text.
The number of lines and the number of characters per line that the <textarea
> can accommodate without scrolling, can be specified with the rows and cols attribute.
The wrap attribute specifies how text wrapping is handled by the element.
Scrollbars appear in the textarea if the text exceeds the number of specified rows or columns.
The CSS overflow attribute, however, can be used to control scrollbar behavior.
textarea defaults to a fixed-pitch font, though CSS font styles may be applied with the style attribute.
The <textarea>
element supports the following attributes, in addition to global attributes common to all HTML elements.
autofocus | autofocus | Specifies that a text area should automatically get focus when the page loads |
cols | number | Specifies the visible width of a text area |
dirname | textareaname.dir | Specifies that the text direction of the textarea will be submitted |
disabled | disabled | Specifies that a text area should be disabled |
form | form_id | Specifies which form the text area belongs to |
maxlength | number | Specifies the maximum number of characters allowed in the text area |
name | text | Specifies a name for a text area |
placeholder | text | Specifies a short hint that describes the expected value of a text area |
readonly | readonly | Specifies that a text area should be read-only |
required | required | Specifies that a text area is required/must be filled out |
rows | number | Specifies the visible number of lines in a text area |
wrap | hard, soft | Specifies how the text in a text area is to be wrapped when submitted in a form |
The following example shows how the textarea element may be used.
<textarea cols="40" rows="5">TEXTAREA automatically provides scrollbars
to accommodate varying amounts of text ... </textarea>
INPUT