Posts in current category

HTML5 <textarea> tag

May 03, 2021 20:00 HTML5

Table of contents

HTML5 is used to create a text box that can enter multiple lines. Please refer to the following example:

An HTML text area:

<textarea rows="10" cols="30">
Try it out . . .

Browser support

HTML5 <textarea> tag HTML5 <textarea> tag HTML5 <textarea> tag HTML5 <textarea> tag HTML5 <textarea> tag

All major browsers support the hashtags.

Label definition and instructions for use

The label defines a multi-line text input control.

An unlimited amount of text can be accommodated in a text area, where the default font for text is an equal width font (usually Courier).

You can specify the size of textarea by using the cols and rows properties, but a better approach is to use the height and width properties of CSS.

The difference between HTML 4.01 and HTML5

HTML5 adds some new properties.


New: The new property in HTML5.

Property Value Describe
autofocus New autofocus Specifies that the text area automatically gets focus when the page is loaded.
cols number Specifies the number of columns visible within the text area.
disabled disabled The text area is specified to be disabled.
form New form_id Define one or more forms to which a text area belongs.
maxlength New number Specifies the maximum number of characters allowed in the text area.
name text Specify the name of the text area.
placeholder New text Specify a short prompt that describes the expected input value for the text area.
readonly readonly Make the text area read-only.
required New required Specify that the text area is required/required.
rows number Specifies the number of lines visible within the text area.
wrap New hard
Specify how the text in the text area should line up when the form is submitted.

Global properties

The label supports the global properties of HTML.

The event property

The tag supports the event properties of HTML.

Related articles

HTML DOM Reference Manual: Textarea Object