The <textarea> element creates a multi-line text input field. It is commonly used in forms to collect feedback, messages, or any longer user input. Unlike single-line text inputs, a textarea gives users more space to type and edit their content. You can control its size, behavior, and constraints with various attributes and CSS.
A well-configured textarea improves usability and accessibility by providing labels, helpful hints, validation, and optional extras like spell checking or character counters.
name attribute is required for the value to be sent during form submission.rows and cols control the visible size, but CSS is preferred for precise layout.placeholder, maxlength, and minlength guide user input.readonly, disabled, and required control how users interact.wrap="soft" or wrap="hard" determine how line breaks are sent to the server.label, id, and aria-describedby help screen reader users.
<label for="message">Your message:</label>
<textarea
id="message"
name="message"
rows="5"
cols="40"
placeholder="Type your message here..."
maxlength="500"
minlength="10"
required
></textarea>
Common attributes:
soft (no extra line breaks in submitted value) or hard (inserts line breaks).spellcheck="true").send).
<form action="#" onsubmit="alert('Form submitted!'); return false;">
<label for="comments">Your Comments:</label>
<textarea
id="comments" <!-- Links label -->
name="comments" <!-- Required for submission -->
rows="6" cols="50"
placeholder="Write your comments here..."
maxlength="500" minlength="10"
wrap="soft" required
spellcheck="true" autocomplete="on"
aria-describedby="comments-help comments-counter"
></textarea>
<small id="comments-help">At least 10 characters.
No personal info, please.</small>
<br><br>
<button type="submit">Submit</button>
</form>
This live demo shows a textarea with validation rules and a character counter. Try typing into the box and watch the counter update as you approach the maximum length.
label and id, and optionally use aria-describedby for help text or counters.min-height, width: 100%) and allow vertical resizing with resize: vertical; for better UX.name set; without it, the textarea value is not included in form submission.placeholder only as a hint, never as the only label — placeholders disappear when the user types.wrap="soft" unless your backend specifically expects hard-wrapped lines.maxlength and minlength when collecting user-generated content, and still validate on the server.spellcheck for comment-like fields, but disable it (spellcheck="false") for code or configuration textareas.resize: none) unless you have a strong layout reason; users often need to expand the box.spellcheck="false" and apply a monospace font via CSS (for example, font-family: monospace;).wrap to hard, submit the form, and inspect how line breaks are included in the submitted value on the server.input event).localStorage on each input, and restore it when the page loads so users don’t lose their text.<textarea> element is used for multi-line user input such as comments and messages.name, rows, cols, placeholder, and maxlength control behavior and usability.