👀 Live Preview
Labeled multi-line input field:

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.
Paragraphs of input.
Initial size hints.
Comments and feedback.
Between open/close tags.
Single vs multi-line.
Labels and styling.
<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.
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.
Wrap default or placeholder text between opening and closing textarea tags:
<textarea>Your text here</textarea><label for="message">Your message</label>
<textarea id="message" name="message" rows="4" cols="50">Type your message here</textarea>textarea must have a closing tag — it is not a void element.label using for and matching id.name when the field submits data in a form.| Topic | Code Snippet | Notes |
|---|---|---|
| Basic textarea | <textarea>...</textarea> | Multi-line |
| Size | rows="4" cols="50" | Initial dimensions |
| Form name | name="comments" | Submission key |
| Placeholder | placeholder="..." | Hint text |
| vs input | textarea = multi-line | input = single-line |
| Browser support | Universal | All browsers |
<textarea> vs <input>Both collect text, but serve different needs:
| Feature | <textarea> | <input> |
|---|---|---|
| Element type | Container with closing tag | Void element |
| Text length | Multi-line paragraphs | Single line |
| Default content | Between opening and closing tags | value attribute |
| Common uses | Comments, messages, descriptions | Name, email, search, password |
The <textarea> tag supports sizing, form, and validation attributes plus global HTML attributes.
<textarea name="message" rows="4" cols="50" placeholder="Type your message">Type your message here</textarea>name FormIdentifies the field when the form is submitted.
name="comments"rows / cols SizingInitial visible height and width. Prefer CSS for responsive layouts.
rows="6" cols="40"placeholder HintShort hint shown when the field is empty (not a substitute for a label).
placeholder="Your feedback"required / maxlength ValidationRequire input or limit character count.
required maxlength="500"Basic text areas, sized fields, and form integration with copy-ready code and live previews.
Labeled multi-line input field:
Use <textarea> for comments, feedback, messages, and any multi-line text input in forms.
The most common use of textarea is a labeled field for user input:
<label for="message">Your message</label>
<textarea id="message" name="message" rows="4" cols="50">Type your message here</textarea>Set initial dimensions with rows and cols:
<textarea rows="6" cols="40">Enter your text here</textarea>Inside a form, textarea lets users submit longer pieces of text:
<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>label for to the textarea id.A labeled textarea is placed inside or outside a form.
The browser renders an editable box that wraps to multiple lines.
On submit, the field’s name sends the text to the server.
Comments, messages, and feedback are collected in a user-friendly way.
The <textarea> tag is supported in all major browsers, including Internet Explorer.
All browsers render <textarea> as an editable multi-line field.
Bottom line: Use <textarea> confidently for multi-line input in any browser.
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.
label for every textarearows based on expected content lengthname when submitting form datavalue attribute (invalid for textarea)input instead)cols for responsive layouts<textarea>Bookmark these before you add multi-line fields to your forms.
Paragraph input.
PurposeNot void.
SyntaxSize hints.
AttributesLong vs short.
ComparisonAlways pair.
A11yAll browsers.
Compatibilitytextarea handles multi-line text with a closing tag. input is a void element for single-line controls.<textarea> and </textarea>, not in a value attribute.rows sets visible height in lines. cols sets visible width in characters.Practice <textarea> fields and form integration in the Try It editor.
6 people found this page helpful