
- HTML Home
- HTML Roadmap
- HTML Introduction
- HTML History & Evolution
- HTML Editors
- HTML Basic Tags
- HTML Elements
- HTML Attributes
- HTML Headings
- HTML Paragraphs
- HTML Fonts
- HTML Blocks
- HTML Style Sheet
- HTML Formatting
- HTML Quotations
- HTML - Comments
- HTML - Colors
- HTML - Images
- HTML - Image Map
- HTML - Frames
- HTML - Iframes
- HTML - Phrase Elements
- HTML - Code Elements
- HTML - Meta Tags
- HTML - Classes
- HTML - IDs
- HTML - Backgrounds
- HTML Tables
- HTML - Tables
- HTML - Table Headers & Captions
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML Color Names & Values
- HTML - Color Names
- HTML - RGB & RGBA Colors
- HTML - HEX Colors
- HTML - HSL & HSLA Colors
- HTML - HSL Color Picker
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - Document Object Model (DOM)
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Picker
- HTML References
- HTML - Cheat Sheet
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Character Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - <textarea> Tag
Introduction to <textarea> Tag
The HTML <textarea> tag is used to define a multiline text input control allowing the users to input more extensive text, such as comments, feedbacks or messages.
Unlike the <input> tag , which is typically used for single line text fields, but the <textarea> element supports multiple lines making it suitable for scenarios needed larger input areas. The default attributes that are automatically added while creating a <textarea> tag as follows −
- id: It allows <textarea> tag to be associated with the label element for accessibility purpose.
- name: It is used to set the name of associated data point submitted to the server when from is submitted.
- rows & cols: HTML row and column attribute the specifies the exact size of the <textarea>.
Syntax
Following is the syntax of HTML <textarea> tag −
<textarea> .... </textarea>
Attributes
HTML textarea tag supports Global and Event attributes of HTML. It also accpets some specific attributes as well which are listed bellow.
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. |
dirname | textareaname.dir | Specifies that the text direction of the textarea will be submitted. |
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 | name | 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 : Basic Textarea
Let's look at the following example, where we are going to consider the basic usage of the <textarea> tag.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML Textarea Tag</title> </head> <body> <!--create a textarea element(tag)--> <textarea></textarea> </body> </html>
Example : Textarea with Placeholder
Consider the following example, where we are going to use the placeholder attribute along with the <textarea> tag.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML Textarea Tag</title> <style> textarea { width: 300px; height: 120px; background-color: aquamarine; padding: 10px 10px; font-size: 18px; color: white; } </style> </head> <body> <!--create a textarea element(tag)--> <h3>Write your feedback: </h3> <textarea placeholder="Write your feedback...."></textarea> </body> </html>
Example : Using disabled Attribute
Let's look at the following example, where we are going to use the disabled attribute along with the <textarea> tag.
<!DOCTYPE html> <html lang="en"> <head> <title>HTML Textarea Tag</title> <style> textarea { width: 300px; height: 100px; background-color: rgb(22, 208, 236); font-size: 18px; padding: 5px 5px; color: white; } </style> </head> <body> <!--create a textarea element(tag)--> <p>Your short story here: </p> <textarea placeholder="Your story..." name='story' disabled> </textarea> </body> </html>
Supported Browsers
Tag | ![]() |
![]() |
![]() |
![]() |
![]() |
---|---|---|---|---|---|
textarea | Yes | Yes | Yes | Yes | Yes |