HTML <textarea> Tag
Description
The <textarea>
HTML element is a form element for creating an area into which multiple lines of text can be entered. In contrast to the <input>
element, it is permissible to do line breaks in the text field; they are preserved when sending data to the server.
Between the <textarea> and </textarea> tags you can put any text that will be displayed inside the field.
Properties
- Permitted Parents
- Any element that accepts phrasing content
- Content
- Text
- Start/End Tags
- Start tag: required, End tag: required
Example
<textarea cols="40">
You can write whatever text you want in the textarea.
</textarea>
Attributes
Attribute | Definition |
---|---|
autofocus | Specifies that a text area should automatically get focus when the page loads |
cols | Specifies the width of the textarea based on the number of visible character widths. |
dirname | Specifies that the text direction of the textarea will be submitted |
disabled | Disables the input control. The button won't accept changes from the user. It also cannot receive focus and will be skipped when tabbing. |
form | Specifies one or more forms the text area belongs to |
maxlength | Specifies the maximum number of characters allowed in the text area |
name | Assigns a name to the input control. |
placeholder | Specifies a short hint that describes the expected value of a text area |
readonly | Sets the textarea to read-only - it won't allow the user to change the value. The textarea however, can receive focus and is included when tabbing through the form controls. |
required | Specifies that a text area is required/must be filled out |
rows | Specifies the height of the textarea based on the number of visible lines of text. If there's more text than this allows, users can scroll using the textarea's scrollbars. |
wrap | Specifies how the text in a text area is to be wrapped when submitted in a form |
Global Attributes
The <textarea>
tag also supports the Global Attributes in HTML5
Event Attributes
The <textarea>
tag also supports the Event Attributes in HTML5
Browser Support
The following table will show you the current browser support for the HTML <textarea>
tag.
Desktop | |||||
12 | 1 | 1 | 12.1 | 4 |
Tablets / Mobile | |||||
18 | 4 | 12.1 | 3 | 1 | 4.4 |
Last updated by CSSPortal on: 30th March 2024