HTML <textarea> Tag

Beginner
6 min read
Updated: Nov 2026
4 examples
Live preview

Definition and Usage

The <textarea> element is a multi-line plain-text control. Use it when users need more than one line — comments, messages, reviews, or notes. For a single line, prefer <input>.

Always pair it with a <label>. Set size with rows / cols (or CSS), and submit the field with name inside a <form>. Put the starting text between the tags — not in a value attribute.

Baseline · Widely available.

Not deprecated. Core textarea support has been stable across browsers since about July 2015 (and much earlier in practice).

Content vs JavaScript.

In HTML, initial text sits between <textarea>…</textarea>. In JavaScript, read/write the current text with the value property.

HTML Syntax

syntax.html
<textarea name=" field">text</textarea>

Both start and end tags are required. Content is plain text only (no nested HTML elements).

Attributes

The attributes you will use most often on <textarea>:

AttributeDescriptionTry it
nameName of the field when the form is submittedTry it
rowsVisible height in text lines (default 2)Try it
colsVisible width in average character widths (default 20)Try it
placeholderShort hint shown when empty (not a substitute for a label)Try it
requiredMust contain a value before the form can submitTry it
maxlength / minlengthMaximum / minimum length in UTF-16 code unitsTry it
readonly / disabledBlock editing; see edge cases for submit/focus differencesTry it
wrapHow line breaks are handled on submit: soft (default), hard, or offSee wrap docs

Also common: autocomplete, autofocus, dirname, form, spellcheck, autocapitalize, and autocorrect.

Global Attributes

The <textarea> tag also supports the Global Attributes in HTML.

Live Preview

Change rows and the placeholder on a real <textarea>.

A labeled <textarea>. Clear the field to see the placeholder again.

Field

rows="5" · placeholder set

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Labeled Textarea

Connect a visible label with matching for / id, and set a name for submit.

HTML
<label for="story">Tell us your story:</label>
<textarea id="story" name="story" rows="4" cols="40">
It was a dark and stormy night…
</textarea>
Try It Yourself

How It Works

  1. Write a <label for="…"> that matches the textarea id.
  2. Add name so the value is included on form submit.
  3. Put starting text between the tags (not as value="…").
  4. Clicking the label focuses the textarea for keyboard and mouse users.

Example 2 — rows, cols, and placeholder

Set a visible size and a short hint for empty fields.

HTML
<label for="comment">Comment</label>
<textarea
  id="comment"
  name="comment"
  rows="5"
  cols="30"
  placeholder="Share a short comment…"
></textarea>
Try It Yourself

How It Works

  1. rows sets how many lines are visible.
  2. cols sets approximate width in characters.
  3. placeholder shows only while the field is empty.
  4. Keep the label — placeholder text is not an accessible name by itself.

Example 3 — required and maxlength

Require a value and cap how many characters the user can enter.

HTML
<form action="/submit" method="post">
  <label for="feedback">Feedback (max 120)</label>
  <textarea
    id="feedback"
    name="feedback"
    rows="4"
    cols="40"
    required
    maxlength="120"
  ></textarea>
  <button type="submit">Send</button>
</form>
Try It Yourself

How It Works

  1. required blocks submit while the field is empty.
  2. maxlength="120" stops typing past 120 characters in supporting UIs.
  3. Optional minlength marks short text invalid, but empty can still pass without required.
  4. Style validity with CSS :valid / :invalid if you want visual feedback.

Example 4 — readonly vs disabled

Both prevent edits; only readonly stays in the submit payload and remains focusable.

HTML
<label for="note-ro">Read-only note</label>
<textarea id="note-ro" name="note_ro" rows="3" cols="30" readonly>
Saved answer — you can select this text.
</textarea>

<label for="note-dis">Disabled note</label>
<textarea id="note-dis" name="note_dis" rows="3" cols="30" disabled>
This value is not submitted.
</textarea>
Try It Yourself

How It Works

  1. readonly: no edits, still focusable, value is submitted.
  2. disabled: no edits, not focusable, value is skipped on submit.
  3. Pick readonly when the user should see/copy a fixed answer that still posts.
  4. Pick disabled when the control is inactive and should not send data.

Edge Cases & Pitfalls

Most textarea issues are missing labels, wrong defaults, or confusing readonly with disabled.

a11y

Placeholder is not a label

Always provide a visible <label>. Placeholder text vanishes while typing and is easy to miss.

content

No value attribute

Initial HTML text goes between the tags. Use the JS value property to read or change the current text.

resize

Users can resize by default

Browsers often show a drag handle. Limit or disable it with CSS resize when layout must stay fixed.

validation

minlength alone allows empty

An empty field can still be valid unless you also set required.

layout

Avoid vertical-align: baseline

Browsers disagree on the textarea baseline, so that alignment can look inconsistent.

Browser Support

The <textarea> element is core HTML form control markup in every browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

<textarea>

Widely available since about July 2015 (and long before). rows, cols, name, placeholder, required, and maxlength work everywhere modern. Some extras like autocorrect vary by engine.

98% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer All
Supported
<textarea> Widely supported

Bottom line: Safe to use for multi-line form text. Label every field, set rows/cols or CSS size, and choose readonly vs disabled carefully.

Key Takeaways

  • Role: <textarea> is for multi-line plain text in forms.
  • Label + name: accessible name in HTML; submitted name in the form data.
  • Size: set rows/cols or CSS; defaults differ by browser.
  • Content: initial text between tags; JS uses the value property.

One line: use a labeled <textarea name="…"> for multi-line text, with rows/cols (or CSS) for a predictable size.

Default CSS Settings

Typical user-agent styling for textarea (simplified; exact rules vary by browser):

default.css
textarea {
  display: inline-block;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  font: inherit;
  /* often resizable by default via the resize property */
}

Set width: 100% and a sensible max-width for mobile layouts, and use resize: vertical (or none) when you need predictable height.

Frequently Asked Questions

The textarea element is a multi-line plain-text field. Use it for comments, messages, reviews, or any longer free-form text in a form.
input is usually one line (text, email, password, and so on). textarea is multi-line. Put the starting text between the textarea tags, not in a value attribute.
No, but setting them is a good habit because browser defaults differ. You can also size the control with CSS width and height.
No. Always use a visible label associated with the textarea. Placeholder is only a short hint and disappears while typing.
Both prevent editing. readonly stays focusable and its value is submitted with the form. disabled is not focusable and is not submitted.
No. An empty textarea can still be valid with minlength unless you also set required.

Next: tfoot

Group footer or summary rows at the bottom of a table.

tfoot tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

12 people found this page helpful