html
/

HTML Textarea: Multi-line Input Fields

Last Sync: Today

On this page

10
0%
5 min read
Remaining
5 minleft

Click any section to jump — progress syncs automatically

html

HTML Textarea: Multi-line Input Fields

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></textarea>

Textarea with Attributes

HTMLRead-only
1
<textarea rows="4" cols="30" placeholder="Enter your message"></textarea>

Common Attributes

AttributeDescription
rowsNumber of visible text lines
colsWidth of textarea
placeholderHint text
maxlengthMaximum characters allowed
requiredMakes field mandatory
readonlyMakes text uneditable
disabledDisables input

Default Text Example

HTMLRead-only
1
<textarea>Default content here...</textarea>

Form Example

HTMLRead-only
1
<form>
  <label>Message:</label>
  <textarea rows="5" cols="40" required></textarea>
  <button type="submit">Send</button>
</form>

Resize Control with CSS

CSSRead-only
1
textarea {
  resize: none;
}

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.

Try it yourself

<textarea rows="4" cols="30" placeholder="Type here..."></textarea>

Test Your Knowledge

Q1
of 3

Which tag is used for multi-line input?

A
<input>
B
<textarea>
C
<text>
D
<area>
Q2
of 3

Which attribute sets number of lines?

A
cols
B
rows
C
lines
D
height
Q3
of 3

Which attribute limits characters?

A
max
B
maxlength
C
limit
D
size

Frequently Asked Questions

What is textarea used for?

It is used for multi-line text input.

What is the difference between input and textarea?

Input is for single-line text, textarea is for multi-line text.

Can I limit characters?

Yes, using the maxlength attribute.

Previous

html select

Next

html tables

Related Content

Need help?

Explore our comprehensive docs or start a chat with our tech experts.