HTML <textarea> Attributes

HTML <textarea> autofocus Attribute

A text area with autofocus:

<textarea autofocus>
At w3schools.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea>

Try it Yourself »


Definition and Usage

The autofocus attribute is a boolean attribute.

When present, it specifies that the text area should automatically get focus when the page loads.

HTML <textarea> cols Attribute

A text area with a specified height and width:

<textarea rows=”4″ cols=”50″>
At w3schools.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea>

Try it Yourself »


Definition and Usage

The cols attribute specifies the visible width of a text area.

Tip: The size of a textarea can also be set by the CSS height and width properties.

HTML <textarea> dirname Attribute

An HTML form where the field’s text direction will be submitted:

<form action=”http://dwf-try.blogspot.com/2018/09/submitted-form-data.html”>
Text:
<textarea name=”explanation” dirname=”explanation.dir”></textarea>
<input type=”submit” value=”Submit”>
</form>

Definition and Usage

The dirname attribute enables the submission of the text direction of the textarea.

The dirname attribute’s value is always the name of the textarea, followed by “.dir”.

HTML <textarea> disabled Attribute

A disabled text area:

<textarea disabled>
At w3schools.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea>

Definition and Usage

The disabled attribute is a boolean attribute.

When present, it specifies that the text area should be disabled.

A disabled text area is unusable and the text is not selectable (cannot be copied).

The disabled attribute can be set to keep a user from using the text area until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript could remove the disabled value, and make the text area usable.

HTML <textarea> form Attribute

A text area located outside a form (but still a part of the form):

<form action=”/action_page.php” id=”usrform”>
Name: <input type=”text” name=”usrname”>
<input type=”submit”>
</form><textarea name=”comment” form=”usrform”>Enter text here…</textarea>

Definition and Usage

The form attribute specifies one or more forms the text area belongs to.

HTML <textarea> maxlength Attribute

A text area with a maximum length of 50 characters:

<textarea maxlength=”50″>
Enter text here…
</textarea>

Definition and Usage

The maxlength attribute specifies the maximum length (in characters) of a text area.

HTML <textarea> name Attribute

A text area with a name attribute:

<form action=”/action_page.php”>
<textarea name=”comment”>Enter text here…</textarea>
<input type=”submit”>
</form>

Definition and Usage

The name attribute specifies a name for a text area.

The name attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted.

HTML <textarea> placeholder Attribute

A text area with a placeholder text:

<textarea placeholder=”Describe yourself here…”></textarea>

Definition and Usage

The placeholder attribute specifies a short hint that describes the expected value of a text area.

The short hint is displayed in the text area before the user enters a value.

HTML <textarea> readonly Attribute

A read-only text area:

<textarea readonly>
At w3schools.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea>

Definition and Usage

The readonly attribute is a boolean attribute.

When present, it specifies that a text area should be read-only.

In a read-only text area, the content cannot be changed, but a user can tab to it, highlight it and copy content from it.

The readonly attribute can be set to keep a user from using a text area until some other condition has been met (like selecting a checkbox, etc.). Then, a JavaScript is required to remove the readonly value, and make the text area editable.

HTML <textarea> required Attribute

A form with a required text area:

<form action=”/action_page.php”>
<textarea name=”comment” required></textarea>
<input type=”submit”>
</form>

Definition and Usage

The required attribute is a boolean attribute.

When present, it specifies that a text area is required/must be filled out (in order to submit the form).

HTML <textarea> rows Attribute

A text area with a specified height and width:

<textarea rows=”4″ cols=”50″>
At w3schools.com you will learn how to make a website. We offer free tutorials in all web development technologies.
</textarea>

Definition and Usage

The rows attribute specifies the visible height of a text area, in lines.

Note: The size of a textarea can also be specified by the CSS height and width properties.

HTML <textarea> wrap Attribute

The text in a text area with wrap=”hard” will contain newlines (if any) when submitted in a form:

<textarea rows=”2″ cols=”20″ wrap=”hard”>
At W3Schools you will find free Web-building tutorials.
</textarea>

Definition and Usage

The wrap attribute specifies how the text in a text area is to be wrapped when submitted in a form.