HTML and CSS  Home HTML and CSS Tutorials The Textarea Tag
rss

The Textarea Tag

Author: webdesign.about More by this author


The Textarea TagThe textarea tag creates a multiple lined text input field in your reader's browser. It allows the reader to type in nearly unlimited lines of text.

When the form is submitted, these lines are sent to the server as the value of the name of the textarea. If your reader hits enter in the field, it is sent to the server as (CR/LF). The textarea tag must always be followed by the closing </textarea> tag.

This tag has several commonly used attributes:

  • cols
  • rows
  • name (required)
  • wrap

cols
The cols attribute indicates how many columns wide the textarea should be.

rows
The rows attribute defines how many rows down the textarea should be.

Neither cols, nor rows are required attributes, but in order to keep your layout I strongly recommend that you set them. You will find that your readers will not want to type more than there is space available (even though there are scroll bars to include additional text), so this is a good way to limit the text submitted by a small amount.

wrap
There are three values for the wrap attribute,virtual,physical, andoff. Off is the default value. This defines how the text behaves within the textarea space.

wrap="off" provides no wrapping. Unless your readers hit <ENTER>, the text they type in will scroll along on one long line. The text will be sent to the server as one long line unless the reader hits the carriage return key.

This is an example of a textarea field where the wrap is turned off.

Click to enlarge
Click to enlarge

wrap="virtual" wraps the text within the space of the text box, but sends it to the server as one long line, as if no wrapping occurred.

This is an example of a textarea field where the wrap is virtual.

Click to enlarge
Click to enlarge

wrap="physical" wraps the text within the text box, and sends it to the server exactly as the reader sees it in the text box.

This is an example of a textarea field where the wrap is physical.

Click to enlarge
Click to enlarge

You can also use style tags on textarea boxes with thestyleandclassattributes. And JavaScript uses the event handlersonFocus,onBlur,onChange, andonSelect. You use these attributes as you would use them in any other HTML tag.

I hope this came in useful!


Rate this Material: Bad 1 2 3 4 5 Excellent
print this page tell a friend subscribe to newsletter subscribe to rss

Add comments to "The Textarea Tag"