Home >Web >HTML reference – elements and attributes >textarea – multi-line text

textarea – multi-line text

<textarea name="message" rows="4">…</textarea>

A field for longer text on several lines: a message, a comment, a note on an order. The text between the tags is the default content of the field (without HTML). The visitor can resize the field by its bottom right corner.

  • Default display: display: inline-block
  • End tag: required
  • Content: text (the default value of the field)
  • Where it can be used: anywhere phrasing content is allowed
  • DOM interface: HTMLTextAreaElement

Attributes

  • name, id – the name of the value and the connection to label.
  • rows, cols – the height in rows (default 2) and the width in characters (default 20). A size in CSS is more common.
  • maxlength, minlength, required, placeholder, readonly, disabled.
  • wrap – soft (default: wrapping only on the screen), hard (also sends the line breaks; needs cols).
  • autocomplete, spellcheck, dirname.

Examples

A note on an order with a limited length, resizable only vertically:

<label for="note">Note on the order</label><br>
<textarea id="note" name="note" rows="3" maxlength="300" placeholder="E.g. I will pick it up after 4 pm"></textarea>
#note {
  width: 100%;
  max-width: 400px;
  resize: vertical;
  font: inherit;
}
result

Things to watch out for

  • Spaces and line breaks between the tags are part of the value: <textarea> </textarea> is not an empty field and does not fail required as empty. Write the tags right next to each other.
  • The content is not treated as HTML – tags in it stay as text. When printing the value from PHP, htmlspecialchars() is enough.
  • The browser displays the field in a monospaced font; font: inherit uses the font of the page.

Browser support

Baseline – widely available: works in all major browsers and has for a long time (since 2015 at the latest). Since version: Chrome 1, Firefox 1, Safari 4. As of October 2026 (MDN browser-compat-data).

Related:
input – input field
label – field label
form – form
spellcheck – spell checking (attribute)