# `<textarea>`

> The `<textarea>` HTML element creates a multiline text input field where users can enter multiple lines of text.

## How do I make a textarea auto-resize to fit its content?

The element that creates a multi-line text input field, allowing users to enter longer pieces of text. It's commonly used in forms where large amounts of input are required, like comments or feedback sections.

- Topic: Forms
- Type: tag
- Browser support: Chrome 1+, Chrome Android 18+, Edge 12+, Firefox 1+, Firefox Android 4+, Safari 4+, Safari iOS 3+

## Example

Wrong:

```html
<textarea name="bio" value="Hello">
</textarea>
```

Right:

```html
<label for="bio">Bio</label>
<textarea id="bio" name="bio" rows="4">Hello</textarea>
```

A textarea's initial text goes between the tags, and whitespace inside is kept, so the closing tag stays on the same line.

## Common mistakes

- Setting a `value` attribute on `<textarea>`, which is ignored.
- Indenting the closing tag, which adds spaces to the default text.

## Key points

- Default text goes between the tags, not in a `value` attribute.
- The `<textarea>` has a linked `<label>` and a `name`.
- Auto-growing uses CSS `field-sizing: content` where supported, with a JS fallback.

## Interview questions

### How do I stop users from resizing a textarea?

Use CSS `resize: none`, or `resize: vertical` to allow only height changes.

### Does maxlength work on textarea?

Yes, `maxlength` limits how many characters users can type.

## Related cards

- [`<input>`](https://wonderium.dev/html/input.md)
- [field-sizing](https://wonderium.dev/css/field-sizing.md)
- [resize](https://wonderium.dev/css/resize.md)
- [`<label>`](https://wonderium.dev/html/label.md)
- [`<form>`](https://wonderium.dev/html/form.md)

---

- Level: [HTML](https://wonderium.dev/html.md)
- HTML version: https://wonderium.dev/html/textarea
- Last updated: 2026-11-25
