<textarea> element is one of the HTML online form elements and defines a multi-line text input area.
When you need user input of more than just a few words such as comments, feedback or order enquiries then the
<textarea> element is the way forward.
The size of the box displayed is governed by the rows and cols attributes. The height of the input box is given as a number of lines of text set with the rows attribute and the width is set as a number of characters(letters, spaces etc.) using the cols attribute. Both of these attributes are obligatory when a
is included in a page.
Example code for a
<textarea> element to gather user comments:
- CORE AND LANGUAGE ATTRIBUTES - class, id, title, style, dir, lang
- MOUSE AND KEYBOARD EVENT ATTRIBUTES - onclick, ondblclick, onmousedown, onmouseup, onmouseover, onmouseout, onmousemove, onkeydown, onkeyup, onkeypress
- name - a name for the
<textarea>element, this value is sent on form submission.
- cols - REQUIRED - sets the width of the
<textarea>element that will be shown on the screen, the value is a number of character units(letters) using the average width of the current character set.
- rows - REQUIRED - the number of rows of text that will be visible when the
<textarea>element is displayed on the screen>
- disabled - sets the
<textarea>element as unavailable.
- readonly - cannot be modified by the user.
- tabindex - gives the position of this element in the tabbing order.
- accesskey - sets a single key to access this element.
- onfocus - defines an event that occurs when the element gains focus.
- onblur - defines an event that occurs when an element loses focus.
- onselect - sets an event to occur when a user selects some text in a text field.
- onchange - sets an event to occur when the
<textarea>element loses focus and it's value has been altered since gaining focus.