HTML Tags

HTML <textarea> Tag

Topic: HTML5 Tags ReferencePrev|Next

Description

The <textarea> tag defines a multi-line text input control within a form.

The text inside the textarea usually rendered in browser's default monospace (fixed-width) font such as Courier. A text area can hold unlimited number of characters.

The following table summarizes the usages context and the version history of this tag.

Placement: Inline
Content: Text
Start/End Tag: Start tag: required, End tag: required
Version: HTML 2, 3.2, 4, 4.01, 5

Syntax

The basic syntax of the <textarea> tag is given with:

HTML / XHTML: <textarea cols="number" rows="number" > ... </textarea>

The example below shows the <textarea> tag in action.

<form>
    <p>Leave your Comment: 
        <textarea cols="60" rows="5">write here...</textarea>
    </p>
</form>

Tag-Specific Attributes

The following table shows the attributes that are specific to the <textarea> tag.

Attribute Value Description
autofocus autofocus Specifies that the textarea should automatically get focus when the document is loaded.
cols number Specifies the number of visible text lines.
disabled disabled This boolean attribute disables the textarea for user input or interaction.
form form-id Specifies the form that the textarea is associated with i.e. its "form owner".
maxlength number Specifies the maximum number of characters that the user can enter in the textarea.
minlength number Specifies the minimum number of characters required that the user should enter in the textarea.
name unique-name Assign a name to the textarea control.
placeholder text Provides a hint to the user of what can be entered in the textarea. Placeholder text must not contain line breaks.
readonly readonly This boolean attribute indicates that the user cannot modify the value of the textarea control (i.e. read-only).
required required This Boolean attribute specifies that the user must fill in a value before submitting the form.
rows number Specifies the visible width in average character widths.
wrap hard
soft
Specifies how the value of the textarea is to be wrapped for form submission.

Global Attributes

Like all other HTML tags, the <textarea> tag supports the global attributes in HTML5.


Event Attributes

The <textarea> tag also supports the event attributes in HTML5.


Browser Compatibility

The <textarea> tag is supported in all major modern browsers.

Browsers Icon

Basic Support—

  • Firefox 1+
  • Google Chrome 1+
  • Internet Explorer 2+
  • Apple Safari 1+
  • Opera 4+

Further Reading

See tutorial on: HTML Forms.

Other form-related tags: <form>, <fieldset>, <legend>, <label>, <input>, <select>, <optgroup>, <option>, <button>.

Bootstrap UI Design Templates Property Marvels - A Leading Real Estate Portal for Premium Properties