The HTML <textarea> tag is employed to specify a text area input control that spans multiple lines.
It has the capability to accommodate an infinite amount of characters, and the content is presented using a monospaced font (typically courier).
The dimensions of the HTML textarea are determined by the rows and cols attribute, or can alternatively be specified using CSS height and width properties.
HTML Textarea Example
Example
<textarea rows="9" cols="70">
C# Tutorial textarea tag example with rows and columns.
</textarea>
Output:
Output
C# Tutorial textarea tag example with rows and columns.
Supporting Browsers
| Element | Chrome | IE | Firefox | Opera | Safari |
|---|---|---|---|---|---|
<textarea> |
Yes | Yes | Yes | Yes | Yes |
New HTML 5 Textarea Attributes
| Attribute | Description |
|---|---|
| autofocus | It specifies that a text area should be automatically get focused when the page is loaded. |
form |
It specifies one or more forms the textarea belongs to. |
| maxlength | It specifies the maximum number of characters allowed in the text area. |
| placeholder | It specifies a short hint that describes the expected value of a textarea. |
| required | It specifies that textarea must be filled out. |
wrap |
It specifies that how the texts in the textarea are wrapped at the time of the submission of the form. |
HTML Textarea form attribute
The form attribute indicates the form or forms to which the text area is associated.
Example
<form action="updates.jsp" id="usrform">
Name: <input type="text" name="usrname">
<input type="submit">
</form>
<br>
<textarea rows="9" cols="70" name="comment" form="usrform">
Enter text here...</textarea>
<p>The text area above is outside the form element, but should still be a part of the form.</p>
<p><b>Note:</b> The form attribute is not supported in Internet Explorer.</p>
Output:
Output
Enter text here...
The textarea element positioned above exists separately from the form, yet it remains an integral component of the form.
Note: The form attribute lacks support in Internet Explorer.