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

NameTypeDescription
autocompleteordered autofill tokens or on/offGives 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.
colspositive integerSets the approximate visible width of a textarea in character columns. The default is 20; CSS can override its rendered size.
dirnameform field nameAdds a separate form data entry recording the directionality of a supported text input or textarea. The submitted direction is ltr or rtl.
disabledbooleanDisables 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.
formform element IDAssociates 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.
maxlengthnon-negative integerLimits 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.
minlengthnon-negative integerSets 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.
namestringProvides 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.
placeholdershort text hintShows a temporary hint when a supported form field is empty. It disappears during entry and is not a substitute for a persistent accessible label.
readonlybooleanPrevents 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.
requiredbooleanMakes supported form controls subject to a nonempty or selected-value constraint. Radio-group and checkbox behavior differs. It does not perform server-side validation.
rowspositive integerSets approximate visible textarea height in lines. The default is 2; CSS can override the rendered height.
wrapenumerated: soft, hardControls 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.
autofocusbooleanRequests initial focus when the document or relevant dialog or popover is shown. Avoid unexpected focus changes that disorient keyboard or screen reader users.
inputmodeenumerated: none, text, decimal, numeric, tel, search, email, urlHints 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.
autocapitalizeenumerated: none, off, sentences, on, words, charactersHints how a virtual keyboard should capitalize text. It is not validation and has no effect on some input types, such as email and password.
autocorrectenumerated: on, offHints whether automatic spelling correction is enabled for editable text. Browser and platform support varies; use off where exact identifiers matter.
enterkeyhintenumerated: enter, done, go, next, previous, search, sendHints 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>
HTML Reference