Encodera

Thanks for reading!

Donate to the site — we work hard for you.

HTML & CSS reference

<textarea>

A multi-line text field.

Syntax

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

Attributes

ParameterTypeDescription
nametextThe name sent to the server.
rows, colsnumberThe height in lines and the width in characters.
maxlengthnumberOptional. The maximum number of characters.

Examples

A field for a review:

<label for="review">Your review</label><br>
<textarea id="review" name="review" rows="4" cols="30" maxlength="200" placeholder="What did you like?"></textarea>

Initial text and vertical-only resizing:

<style>
  textarea { width: 100%; resize: vertical; }
</style>
 
<textarea rows="3">Text between the tags is the initial value.</textarea>

Notes

The initial value goes between the tags, not into a value attribute. All spaces and line breaks inside are kept, so put the closing tag right after the text. Resizing is controlled by the CSS resize property.

See also

  • <input> — An input field; its kind is set by the `type` attribute.
  • <label> — A label for a form field.
  • placeholder — A hint or example inside an empty field.

Related recipes

In the tutorial

Thanks for reading!

Donate to the site — we work hard for you.