HTML <textarea> Tag

Beginner
⏱️ 6 min read
📚 Updated: Jun 2026
🎯 3 Examples
Forms & Input

What You’ll Learn

The <textarea> tag creates a multi-line text input field. This guide covers syntax, attributes, form integration, textarea vs input, accessibility, and best practices for beginners.

01

Multi-line Text

Paragraphs of input.

02

rows & cols

Initial size hints.

03

Form Fields

Comments and feedback.

04

Default Text

Between open/close tags.

05

vs input

Single vs multi-line.

06

Best Practices

Labels and styling.

What Is the <textarea> Tag?

The <textarea> tag is an HTML form control that lets users enter multiple lines of text. Unlike <input type="text">, which handles single-line input, textarea is ideal for comments, messages, descriptions, and other longer content.

Valid HTML5 — Multi-line Form Control

textarea is a container element with opening and closing tags. Default text goes between the tags, not in a value attribute.

Common uses include contact form messages, feedback boxes, review text, and any form field that needs more than one line of user input.

📝 Syntax

Wrap default or placeholder text between opening and closing textarea tags:

syntax.html
<textarea>Your text here</textarea>

Labeled Example

labeled-textarea.html
<label for="message">Your message</label>
<textarea id="message" name="message" rows="4" cols="50">Type your message here</textarea>

Syntax Rules

  • textarea must have a closing tag — it is not a void element.
  • Put default text between the tags; use an empty textarea for a blank field.
  • Always pair with a label using for and matching id.
  • Use name when the field submits data in a form.

⚡ Quick Reference

TopicCode SnippetNotes
Basic textarea<textarea>...</textarea>Multi-line
Sizerows="4" cols="50"Initial dimensions
Form namename="comments"Submission key
Placeholderplaceholder="..."Hint text
vs inputtextarea = multi-lineinput = single-line
Browser supportUniversalAll browsers

⚖️ <textarea> vs <input>

Both collect text, but serve different needs:

Feature<textarea><input>
Element typeContainer with closing tagVoid element
Text lengthMulti-line paragraphsSingle line
Default contentBetween opening and closing tagsvalue attribute
Common usesComments, messages, descriptionsName, email, search, password

🧰 Attributes

The <textarea> tag supports sizing, form, and validation attributes plus global HTML attributes.

attributes.html
<textarea name="message" rows="4" cols="50" placeholder="Type your message">Type your message here</textarea>
name Form

Identifies the field when the form is submitted.

name="comments"
rows / cols Sizing

Initial visible height and width. Prefer CSS for responsive layouts.

rows="6" cols="40"
placeholder Hint

Short hint shown when the field is empty (not a substitute for a label).

placeholder="Your feedback"
required / maxlength Validation

Require input or limit character count.

required maxlength="500"

Examples Gallery

Basic text areas, sized fields, and form integration with copy-ready code and live previews.

👀 Live Preview

Labeled multi-line input field:

📚 Common Use Cases

Use <textarea> for comments, feedback, messages, and any multi-line text input in forms.

Basic Text Area

The most common use of textarea is a labeled field for user input:

basic-text-area.html
<label for="message">Your message</label>
<textarea id="message" name="message" rows="4" cols="50">Type your message here</textarea>
Try It Yourself

Sized Text Area

Set initial dimensions with rows and cols:

sized-textarea.html
<textarea rows="6" cols="40">Enter your text here</textarea>
Try It Yourself

Form Integration

Inside a form, textarea lets users submit longer pieces of text:

form-integration.html
<form action="/submit" method="post">
  <label for="comments">Comments</label>
  <textarea id="comments" name="comments" rows="8" cols="60">Type your comments here</textarea>
  <button type="submit">Submit</button>
</form>
Try It Yourself

♿ Accessibility

  • Always use a label — Connect label for to the textarea id.
  • Do not rely on placeholder alone — Placeholder text is not a replacement for a visible label.
  • Provide instructions — Use helper text for character limits or formatting expectations.
  • Ensure keyboard access — Textareas are focusable by default; avoid disabling without good reason.

🧠 How <textarea> Works

1

Author adds the field

A labeled textarea is placed inside or outside a form.

Markup
2

User types multi-line text

The browser renders an editable box that wraps to multiple lines.

Input
3

Form submits the value

On submit, the field’s name sends the text to the server.

Submit
=

Longer user input captured

Comments, messages, and feedback are collected in a user-friendly way.

Browser Support

The <textarea> tag is supported in all major browsers, including Internet Explorer.

Baseline · HTML4 / HTML5

Multi-line input everywhere

All browsers render <textarea> as an editable multi-line field.

100% Core tag support
Google Chrome Fully supported
Full support
Mozilla Firefox Fully supported
Full support
Apple Safari Fully supported
Full support
Microsoft Edge Fully supported
Full support
Internet Explorer Fully supported · EOL
Full support
Opera Fully supported
Full support
<textarea> tag 100% supported

Bottom line: Use <textarea> confidently for multi-line input in any browser.

Conclusion

The <textarea> tag is essential for collecting multi-line text on the web. With proper labels, sizing, and form integration, you provide a clear, accessible way for users to submit comments, messages, and longer feedback.

💡 Best Practices

✅ Do

  • Include a descriptive label for every textarea
  • Set rows based on expected content length
  • Use CSS for responsive width and polished styling
  • Add name when submitting form data

❌ Don’t

  • Use placeholder as the only label
  • Put default text in a value attribute (invalid for textarea)
  • Use textarea for single-line input (use input instead)
  • Rely only on cols for responsive layouts

Key Takeaways

Knowledge Unlocked

Six truths every developer should know about <textarea>

Bookmark these before you add multi-line fields to your forms.

6
Core concepts
📋 02

Closing tag

Not void.

Syntax
📏 03

rows / cols

Size hints.

Attributes
⚖️ 04

vs input

Long vs short.

Comparison
05

Label

Always pair.

A11y
🌐 06

100% Support

All browsers.

Compatibility

❓ Frequently Asked Questions

It creates a multi-line text input for comments, messages, feedback, and other longer form content.
textarea handles multi-line text with a closing tag. input is a void element for single-line controls.
Place the text between <textarea> and </textarea>, not in a value attribute.
rows sets visible height in lines. cols sets visible width in characters.
Yes. Full support in every major browser including Internet Explorer.

Collect multi-line feedback

Practice <textarea> fields and form integration in the Try It editor.

Try basic textarea example →

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.

6 people found this page helpful