Home > Abakada: Back to Basics > Language References > HTML Elements > TEXTAREA Element
Specifies a scrollable text box. | HTML 2, 3.2, 4, 4.01, 5 |
HTML Syntax
<textarea
accesskey = key
class = classname
cols = n
datafld = colname
datasrc = #id
disabled
id = value
name = name
readonly
rows = n
style = css_style_rules
tabindex = n
title = text
wrap = off | hard | soft
>
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.
NOTE: Both start and end tags are required.
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 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