CKTIS / HTML
textarea — multiline text control
The textarea element edits multiline plain text. Learn how its initial and current values differ, how to label it, and how it participates in a form.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
<textarea id="message" name="message" rows="4" cols="40">Initial text</textarea>textarea is a multiline plain-text editing control, not an HTML editor. It requires an end tag. Text between its tags supplies the default value; a value attribute does not set that default.
In JavaScript, the value property reads or changes the current value, while defaultValue corresponds to the default text. Resetting the form restores the default value. The example demonstrates this distinction without user interaction.
Associate a label using matching for and id values; placeholder does not replace a label. name identifies the field in form submission. rows and cols specify control dimensions, not a text-length limit.
required demands a nonempty value in an editable control. readonly prevents editing but does not exclude the value from submission; disabled prevents interaction and excludes the value from submission. Both bar the control from constraint validation.
Examples
<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>Textarea example</title>
<form id="form">
<label for="message">Message</label>
<textarea id="message" name="message" rows="3" cols="30" required>Hello</textarea>
</form>
<pre id="result"></pre>
<script>
const form = document.getElementById('form');
const message = document.getElementById('message');
const lines = [];
lines.push(message.value);
message.value = 'Updated';
lines.push(message.value);
lines.push(message.defaultValue);
form.reset();
lines.push(message.value);
document.getElementById('result').textContent = lines.join('\n');
</script>
</html>Result
Hello Updated Hello Hello
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.