WEEK: 5
Active: Not Currently Active
Work Due:

The Textarea Element

The textarea input type can be used to create an input field element where users can enter longer responses.

NOTE: This field uses an opening and closing tag pair. Any text between these tags will initially inhabit the box.

Additional Optional Attributes

cols & rows

You can specify the number of cols and rows through the appropriate attributes. This changes the size of the displayed element, as well as how text will look when typed.

  • cols; this is the width of the textarea in character widths (i.e. this is the number of characters that will fit from left to right).
  • rows; this is the number of visible lines.

NOTE: Typically, and as is the case with many size parameters that you can set in HTML, you should override these parameters with CSS. See the following code example.

<form action="http://www.example.com/comments.php">
    <h2>Type a long story:</h2>
    <textarea name="comments" cols="20" rows="4" style="min-width:100%">
    Enter your comments...
    </textarea>
</form>

Type a long story:


Previous section:
Next section: