HTML <textarea> tag
The <textarea> tag is used to define a multi-line text input control for users. By default, the texts within this element is rendered in monospace (usually Courier) or fixed-width font.
It is possible to have unlimited number of characters within this element.
Type: Block Element
Syntax of <textarea> tag
<textarea> -- Content -- </textarea>
Supported Browsers
| Tag | Chrome | Internet Explorer | Firefox | Safari | Opera Mini |
|---|---|---|---|---|---|
| <textarea> | Yes | Yes | Yes | Yes | Yes |
Full code example
<!DOCTYPE <html> <head> </head> <body> <textarea rows="5" cols="30"> The HTML heading is used to define heading of an HTML document. It is also among the most commonly used HTML elements. Heading is very important in every page. All pages include heading part. For example if you want to write an essay about 'Games and Sports' in examination, firstly you give heading as "Games and Sports" before writing content. Apart from examination, any web-page requires heading section. </textarea> </body> </html>
Output on the browser
rows→ Number of visible lines.
cols→ Width of the tetxarea.
Attributes of <textarea> tag
| Attribute | Value | Notes |
|---|---|---|
| autofocus | autofocus | It specifies that a form control should automatically get focused when the page loads until the user overrides it. |
| cols | number | It specifies the visible width of the textarea control. |
| disabled | disabled | If this attribute is specified, the textarea is disabled i.e., users cannot interact with the textarea. |
| form | form_id | It specifies one or more forms that the textarea belongs to. |
| maxlength | number | It defines the maximum number of characters that can be written inside the textarea. |
| minlength | number | It defines the minimum number of characters that should be written inside the textarea. |
| name | text | It defines the name of the textarea element. |
| placeholder | text | It gives a short hint to the user about what can be entered inside the textarea element. |
| readonly | readonly | It disallows the users to change the texts or any characters contained inside the textarea element. |
| required | required | It specifies that the textarea should be filled-up in order to submit the relative form. |
| rows | number | It specifies the visible number of lines of the textarea. |
| spellcheck | true false |
It is used to find error like mistake in grammar or spelling. |
| wrap | hard soft |
It is used to find error like mistake in grammar or spelling. |
