Course contentsShow
← Web Development
Lesson 99 of 2,9822. HTML FundamentalsFree lesson

The <textarea> Element

Creating multi-line text inputs with rows, cols, and resize behavior control.

The <textarea> Element

You'll learn how to create multi-line text input fields that users can resize and type paragraphs into.

What is <textarea>?

While single-line inputs (like <input type="text">) work great for names or emails, sometimes you need users to write multiple lines of text—like comments, messages, or descriptions. That's where <textarea> comes in. Think of it as the difference between a single sticky note and a full notepad page.

Unlike <input>, which is self-closing, <textarea> is a paired element with opening and closing tags. Any text between the tags becomes the default content.

Basic Structure

<form>
  <label for="feedback">Your Feedback:</label>
  <textarea id="feedback" name="feedback"></textarea>
</form>

Controlling Size with rows and cols

You can set the visible size using two attributes:

  • rows: Number of visible text lines (height)
  • cols: Width in average character width
<textarea id="bio" name="bio" rows="5" cols="40"></textarea>

Controlling Resize Behavior

By default, users can drag the corner to resize a textarea. While styling (CSS) ultimately controls this, you should know textareas are inherently resizable—unlike fixed-size inputs.

Default Content

Unlike <input> which uses value="", textarea's default text goes between the tags:

<textarea name="message" rows="3" cols="30">Type your message here...</textarea>

Key Takeaway: The <textarea> element creates multi-line text inputs, sized with rows and cols attributes, perfect for collecting longer-form user content like comments or descriptions.