HTML5 <textarea> Tag


A simple textarea:

<textarea rows="2" cols="20">
At W3Tutors you will find all the Web-building tutorials you need, from basic HTML to advanced XML, SQL, ASP, and PHP.

Try it yourself »

Definition and Usage

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

A text area can hold an unlimited number of characters, and the text renders in a fixed-width font (usually Courier).

The size of a textarea can be specified by the cols and rows attributes, or even better; through CSS' height and width properties.

Differences Between HTML 4.01 and HTML5

HTML5 has some new attributes: autofocus, form, maxlength, placeholder, required, and wrap.


New : New in HTML5.

Attribute Value Description
autofocusNew autofocus Makes the text area focused on page load
cols number Specifies the number of characters visible in the text area
disabled disabled Disables the text area when it is first displayed
dirnameNew fieldname Specifies the name of an input field containing the text direction of the text area
formNew formname Defines one ore more forms the text area belongs to
maxlengthNew number Defines the maximum number of characters allowed in the text area
name name Specifies a name for the text area
placeholderNew text Defines a hint to help users fill out the text area
readonly readonly Indicates that the user cannot modify the content in the text area
requiredNew required Defines if the text area value is required in order to submit the form.
rows number Specifies the number of rows visible in the text area
wrapNew hard
Specifies how the text in the text area is wrapped, and if it should be wrapped when submitted in a form

Standard Attributes

The <textarea> tag also supports the Standard Attributes in HTML5.

Event Attributes

The <textarea> tag also supports the Event Attributes in HTML5.