<textarea>
Example
<textarea name="bio" value="Hello">
</textarea><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
valueattribute 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
valueattribute. - The
<textarea>has a linked<label>and aname. - Auto-growing uses CSS
field-sizing: contentwhere 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.