 
  Data Structure Data Structure
 Networking Networking
 RDBMS RDBMS
 Operating System Operating System
 Java Java
 MS Excel MS Excel
 iOS iOS
 HTML HTML
 CSS CSS
 Android Android
 Python Python
 C Programming C Programming
 C++ C++
 C# C#
 MongoDB MongoDB
 MySQL MySQL
 Javascript Javascript
 PHP PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use a textarea (a multi-line text input field) in HTML?
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 −
| Attribute | Value | Description | 
|---|---|---|
| autofocus   | autofocus | Specifies that on page load the text area should automatically get focus. | 
| Cols | number | Specifies the width of the textarea based on the number of visible character widths | 
| Disabled | disabled | Specifies the width of the textarea based on the number of visible character widths. | 
| form   | form_id | Specifies one or more forms. | 
| maxlength   | number | Specifies the maximum number of characters in textarea. | 
| Name | text | Assigns a name to the input control. | 
| placeholder   | text | Specifies a short hint of the value in textarea. | 
| Readonly | readonly | Sets 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. | 
| required   | required | Specifies that a textarea is required. | 
| Rows | number | 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   | hard soft | Specifies 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> <head> <title>HTML textarea Tag</title> </head> <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>
Advertisements
 