What is HTML Textarea?
The <textarea> element is used to create a multi-line text input field, commonly used for comments, messages, and descriptions.
Basic Syntax
HTMLRead-only
1
Textarea with Attributes
HTMLRead-only
1
Common Attributes
| Attribute | Description |
|---|---|
| rows | Number of visible text lines |
| cols | Width of textarea |
| placeholder | Hint text |
| maxlength | Maximum characters allowed |
| required | Makes field mandatory |
| readonly | Makes text uneditable |
| disabled | Disables input |
Default Text Example
HTMLRead-only
1
Form Example
HTMLRead-only
1
Resize Control with CSS
CSSRead-only
1
Best Practices
- Use placeholder for guidance
- Set appropriate rows and cols
- Limit input using maxlength
- Use labels for accessibility
- Allow resizing only when needed
Common Mistakes
- Not using labels
- Allowing unlimited input without validation
- Using textarea for short inputs unnecessarily
- Disabling resize when user needs flexibility
Conclusion
HTML textarea is essential for collecting longer user input. Proper configuration ensures better usability and user experience.