HTML Dog
Skip to navigation

HTML Tag: textarea

A multi-line text form field, allowing input from a user.

Any content of the textarea element will be the field’s initial value.

Optional Attributes

Attribute Description Possible values
name Name of the form control, to be paired with its value. Text (no spaces).
maxlength The maximum number of permissible characters. Number.
minlength The minimum number of permissible characters. Number.
disabled Disables the form control. None.
readonly Makes the form control unalterable by the user. None.
autocomplete If a browser should implement autocomplete on the control or not.
  • on (default)
  • off
autofocus Indicates that the form control should have focus on page load. Should only be used on one form control in a page. None.
dirname Adds an additional field to be sent containing the directionality of the form control’s value. Text (no spaces). dirname="this.dir" will append this.dir=ltr (left-to-right) or this.dir=rtl (right-to-left) to submitted data, for example.
form Explicitly associates the control to a form element, which it may or may not be nested within. If absent, the control will be associated to its form ancestor. Text matching the value of a form element’s id attribute.
placeholder A visible hint as to what kind of data the user should input. Text.
required Indicates that the form field must be completed. None.
rows The expected number of required lines. Number. Default is 2.
cols The expected number of required characters in a line. Number. Default is 20.
wrap If text should be wrapped when submitted.
  • soft (default): Should not be wrapped.
  • hard: Should be wrapped.
Global attributes

Example


<label for="why">Why do you consider yourself hilarious?</label>
<textarea name="why" id="why" required>I am hilarious because...</textarea>

<label for="how">How hilarious are you? (in 100 characters or less)</label>
<textarea placeholder="As hilrious as a clown? As hilarious as Donald Trump's hair?" maxlength="100" name="how" id="how"></textarea>