HTML Textarea

HTML Textareas: When One Line Just Isn’t Enough

Not all inputs are short. Sometimes users need to write a paragraph — a comment, a message, a description. That’s where the <textarea> tag shines. It lets users enter multiline text with room to think and express more.

Basic Structure of a Textarea

The <textarea> element is not self-closing. You use an opening tag, closing tag, and the content goes inside.

<label for="message">Your Message:</label><br>
<textarea id="message" name="message"></textarea>
Your Message:
[                     ]
[                     ]
[                     ]

By default, the box may be small. You can customize its size with attributes.

Setting Rows and Columns

Use the rows and cols attributes to control visible height and width of the textarea.

<textarea name="comments" rows="4" cols="30"></textarea>
[                           ]
[                           ]
[                           ]
[                           ]

This creates a box that's 4 lines tall and 30 characters wide.

Adding Placeholder Text

Just like with <input>, you can guide users using the placeholder attribute.

<textarea name="feedback" rows="4" cols="40" placeholder="Tell us what you think..."></textarea>
[ Tell us what you think... ]

The placeholder disappears when the user starts typing.

Pre-Filling a Textarea

You can place default text between the opening and closing <textarea> tags.

<textarea name="note">Hello World</textarea>
[ Hello World ]

This is useful for preloaded notes or editing existing content.

Using Textarea Inside a Form

<form action="/submit" method="post">
  <label for="review">Write your review:</label><br>
  <textarea id="review" name="review" rows="5" cols="50" placeholder="Your experience with the banana...></textarea><br><br>
  <input type="submit" value="Submit">
</form>
Write your review:
[ Your experience with the banana...       ]
[                                           ]
[                                           ]
[                                           ]
[                                           ]
[Submit]

When submitted, the content inside the textarea is sent as the value of the name attribute.

Textarea Styling Tip

By default, users can resize textareas. You can control this using CSS (covered later), but in basic HTML, it's helpful to define rows and cols thoughtfully.

Best Practices

  • Always label your textarea to improve accessibility
  • Use placeholders for helpful hints, not essential instructions
  • Don’t over-restrict size; give space to express
  • Use default text sparingly so users don’t accidentally submit unchanged content

Full Example: Fruit Feedback Form

<form action="/submit-feedback" method="post">
  <label for="fruit">Which fruit did you try?</label><br>
  <input type="text" id="fruit" name="fruit" placeholder="Apple, Banana, Cherry..."><br><br>

  <label for="comment">Share your experience:</label><br>
  <textarea id="comment" name="comment" rows="4" cols="50" placeholder="Was it sweet? Fresh? Juicy?"></textarea><br><br>

  <input type="submit" value="Send Feedback">
</form>
Which fruit did you try?
[ Apple, Banana, Cherry... ]

Share your experience:
[ Was it sweet? Fresh? Juicy?             ]
[                                         ]
[                                         ]
[                                         ]

[Send Feedback]

Summary

The <textarea> tag gives users the space to say more — and sometimes, that’s exactly what your form needs. You’ve now learned to:

  • Create multi-line input fields using <textarea>
  • Set visible dimensions using rows and cols
  • Guide users with placeholder text
  • Pre-fill fields with default values

Check your understanding 1

Which HTML tag is used to allow users to enter multiline text input?
Choose one answer. You can try again.

Answer and explanation

<code><textarea></code>

The <textarea> tag is used for multiline text input. It differs from <input type="text"> by allowing line breaks and longer content, useful in feedback or essay forms.

Check your understanding 2

The <textarea> tag supports attributes like rows and cols to control its size.
Choose one answer. You can try again.

Answer and explanation

True

Yes, rows defines the visible number of lines, and cols sets the width in characters. You can also use CSS for more responsive control.

Check your understanding 3

Choose the option that lists all and only the correct statements.

  1. placeholder
  2. name
  3. rows
  4. type
Which of the following are valid attributes for the <textarea> tag?
Choose one answer. You can try again.

Answer and explanation

Statements 1 and 2 and 3

<textarea> does not use type. The valid attributes are name (for identifying field in submission), rows, and placeholder for hint text.

Check your understanding 4

What is the main purpose of using a <textarea> element in a school admission form?
Choose one answer. You can try again.

Answer and explanation

To write a personal statement or feedback

<textarea> is ideal for collecting open-ended responses like 'Why do you want to join this school?' or 'Describe your achievements in brief.'

Check your understanding 5

Content inside a <textarea></textarea> is treated as its default value.
Choose one answer. You can try again.

Answer and explanation

True

Yes, unlike input elements, a <textarea> uses its inner text (between opening and closing tags) as its default content, which can be pre-filled.

Check your understanding 6

Choose the option that lists all and only the correct statements.

  1. <textarea name="remarks" rows="4" cols="30">Initial note</textarea>
  2. <textarea placeholder="Write your feedback here..."></textarea>
  3. <textarea type="text">Hello</textarea>
  4. <textarea name="bio" rows="5" cols="40"></textarea>
Which of these examples demonstrate proper usage of <textarea>?
Choose one answer. You can try again.

Answer and explanation

Statements 1 and 2 and 4

The third option is incorrect as <textarea> does not support the type attribute. All others are valid and commonly used in forms.

What’s Next?

In the next tutorial, we’ll bring it all together by exploring Submit and Reset Buttons — the final step in any HTML form journey.

Reaching the recap and completing the quizzes are separate milestones.

    Next lesson: HTML Submit and Reset Buttons →