Forms & Controls
HTML <textarea> element
Creates a multiline plain-text control. Initial text is written between the tags rather than using a value content attribute. Set rows and cols for a useful initial size or use CSS. A label remains visible after typing; placeholder is only a hint. The current value can differ from the initial text content. It accepts global HTML attributes; individual global features may be inapplicable or restricted.
Formal Syntax & Structure
html syntaxhtml
<textarea name="message"></textarea>Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| autocomplete | ordered autofill tokens or on/off | Gives the browser the purpose of a form field or controls autofill. Use meaningful tokens such as email or current-password. A browser may still offer password-manager autofill even with off. |
| cols | positive integer | Sets the approximate visible width of a textarea in character columns. The default is 20; CSS can override its rendered size. |
| dirname | form field name | Adds a separate form data entry recording the directionality of a supported text input or textarea. The submitted direction is ltr or rtl. |
| disabled | boolean | Disables supported controls or elements. Disabled form controls are generally not focusable, validated or submitted. The exact effect depends on the element; disabled="false" still disables. |
| form | form element ID | Associates an eligible control with a form elsewhere in the same document, overriding an ancestor form where applicable. Does not automatically associate descendants of a fieldset. |
| maxlength | non-negative integer | Limits text length in applicable inputs and textareas, measured in UTF-16 code units. It is not a byte limit or a reliable count of user-perceived characters. |
| minlength | non-negative integer | Sets the minimum length of user-entered nonempty text in applicable fields, measured in UTF-16 code units. Add required if an empty value must also be invalid. |
| name | string | Provides an element-specific name: a form field key, radio group name, named frame, metadata key, slot name or other defined purpose. Its meaning depends on the element; it is not a unique DOM identifier. |
| placeholder | short text hint | Shows a temporary hint when a supported form field is empty. It disappears during entry and is not a substitute for a persistent accessible label. |
| readonly | boolean | Prevents user editing of eligible inputs and textareas without disabling their normal submission. It does not apply to every control type, and scripts can still alter the value. |
| required | boolean | Makes supported form controls subject to a nonempty or selected-value constraint. Radio-group and checkbox behavior differs. It does not perform server-side validation. |
| rows | positive integer | Sets approximate visible textarea height in lines. The default is 2; CSS can override the rendered height. |
| wrap | enumerated: soft, hard | Controls textarea submission wrapping. soft is the default and does not add line breaks for visual wrapping; hard can insert line breaks based on cols when submitted. |
| autofocus | boolean | Requests initial focus when the document or relevant dialog or popover is shown. Avoid unexpected focus changes that disorient keyboard or screen reader users. |
| inputmode | enumerated: none, text, decimal, numeric, tel, search, email, url | Hints which virtual keyboard layout to present. It does not constrain permitted values or perform validation. Use it for text identifiers that need a numeric keypad. |
| autocapitalize | enumerated: none, off, sentences, on, words, characters | Hints how a virtual keyboard should capitalize text. It is not validation and has no effect on some input types, such as email and password. |
| autocorrect | enumerated: on, off | Hints whether automatic spelling correction is enabled for editable text. Browser and platform support varies; use off where exact identifiers matter. |
| enterkeyhint | enumerated: enter, done, go, next, previous, search, send | Hints which action label or icon a virtual keyboard should show for Enter. It does not implement form submission or navigation. |
Return Value
HTMLTextAreaElement
Content model: Text only; initial value is text between tags.
Working Example
Example Snippethtml
<!doctype html><html lang="en"><head><meta charset="utf-8"><title>HTML example</title></head><body><label for="note">Note</label><textarea id="note" name="note" rows="4" cols="30"></textarea></body></html>