# How to use a textarea (a multi-line text input field) in HTML?

HTMLWeb DevelopmentFront End Technology

To add a multi-line text input, use the HTML <textarea> tag. You can set the size of a text area using the cols and rows attributes. It is used within a form, to allow users to input text over multiple rows.

Here are the attributes of <textarea> tag −

AttributeValueDescription
autofocusautofocusSpecifies that on page load the text area should automatically get focus.
ColsnumberSpecifies the width of the textarea based on the number of visible character widths
DisableddisabledSpecifies the width of the textarea based on the number of visible character widths.
formform_idSpecifies one or more forms.
maxlengthnumberSpecifies the maximum number of characters in textarea.
NametextAssigns a name to the input control.
placeholdertextSpecifies a short hint of the value in textarea.
ReadonlyreadonlySets the input control to read-only. It won't allow the user to change the value. The control however, can receive focus and are included when tabbing through the form controls.
requiredrequiredSpecifies that a textarea is required.
RowsnumberSpecifies 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.
wraphard softSpecifies the text to be wrapped in textarea.

## Example

You can try to run the following code to use a textarea in HTML −

<!DOCTYPE html>
<html>
<title>HTML textarea Tag</title>

<body>
<form action = "/cgi-bin/hello_get.cgi" method = "get">
What improvements you want in college?
<br>

<textarea rows = "4" cols = "40" name = "description">
Enter details here...
</textarea>
<br>

<input type = "submit" value = "submit" />
</form>

</body>
</html>
Published on 23-Jan-2018 06:23:34