<textarea>
A multi-line text field.
Syntax
<textarea name="message" rows="4"></textarea>Attributes
| Parameter | Type | Description |
|---|---|---|
| name | text | The name sent to the server. |
| rows, cols | number | The height in lines and the width in characters. |
| maxlength | number | Optional. The maximum number of characters. |
Examples
A field for a review:
<label for="review">Your review</label><br>
<textarea id="review" name="review" rows="4" cols="30" maxlength="200" placeholder="What did you like?"></textarea>Initial text and vertical-only resizing:
<style>
textarea { width: 100%; resize: vertical; }
</style>
<textarea rows="3">Text between the tags is the initial value.</textarea>Notes
The initial value goes between the tags, not into a value attribute. All spaces and line breaks inside are kept, so put the closing tag right after the text. Resizing is controlled by the CSS resize property.
See also
- <input> — An input field; its kind is set by the `type` attribute.
- <label> — A label for a form field.
- placeholder — A hint or example inside an empty field.
Related recipes
In the tutorial
- Select lists and multi-line text — The select dropdown and option, optgroup groups, choosing several options, textarea and datalist suggestions.