<textarea>: The TEXTAREA Element
Last updated: 2026-10-13
<textarea>The TEXTAREA Element
A multi-line plain-text input, ideal for comments, messages or code.
| Category | Forms |
|---|---|
| Content Model | Flow content |
| Allowed Parents | Any element that accepts flow content |
| Content Tag | Yes — requires closing </textarea> tag |
| Status | Standard |
📝 Syntax
<textarea name="msg" rows="4" cols="50">Default text</textarea>
⚙️ Attributes
This element supports the global attributes plus the following:
| Attribute | Value | Description |
|---|---|---|
name | Field name sent to the server. | |
rows | Number of visible rows. | |
cols | Number of visible columns (width). | |
placeholder | Hint shown when empty. | |
required | Must be filled before submit. | |
maxlength | Maximum number of characters. | |
readonly | Read-only, not editable. | |
disabled | Disables the field. | |
wrap | Wrapping: soft or hard. |
▶ Example
Edit the code below and see the live result in the playground:
🌐 Browser Support
| Browser | |||||
|---|---|---|---|---|---|
| <textarea> | ✓ v1 | ✓ v12 | ✓ v1 | ✓ v1 | ✓ v1 |
| Supported in all major browsers | |||||
Tip: The default value goes between the tags, not in a value attribute.
❓ FAQ
QHow do I size a textarea?
ATwo layers: the default size comes from the
rows and cols attributes (line count and column width); whether users can drag-resize is CSS resize (none, vertical, or both). Modern layouts often set width/height in CSS directly.QWhere does the initial value of textarea go?
ABetween the opening and closing tags:
<textarea>initial content</textarea>. Unlike input, it has no value attribute (placeholder still works). In JS, read the current value with textarea.value.QCan I limit the input length of a textarea?
AYes —
maxlength hard-limits input (typing beyond is blocked) and minlength joins validation for the minimum. Note maxlength counts characters including newlines, which may not match backend byte limits; keep frontend and backend rules aligned.🏷️ Related Tags
💡 Related Cases
More case studies coming soon — check back later.