Text areas are for larger areas of text, such as a comments entry area in a form. <textarea>
is not specified as the attribute of an <input>
tag, but is its own tag.
<textarea>
is also an exception to most of the form-specific tags we have seen thus far in that it is a closed tag. If you ever see HTML spilling inside a <textarea>
when you view a form in a browser, you know that you haven’t closed the <textarea>
properly, filling the area with anything that comes immediately after the opening tag:
<label for="comment" accesskey="m">Your comments</label>
<textarea name="comment" id="comment" rows="5" cols="80">
This is some default text
</textarea>
The size of a <textarea>
is also defined differently from other elements, through rows
and cols
attributes (respectively, the number of lines and characters per line that can be displayed in the <textarea>
).
Photograph by Speg of the Pigs, used under a Creative Commons Attribution-NonCommercial 2.0 Generic license
Enjoy this piece? I invite you to follow me at twitter.com/dudleystorey to learn more.