form tag
button tag
input tag
select tag
optgroup tag
option tag
TAG: textarea
<textarea> ... </textarea>
The
textarea
tag is used to create a multi-line text input window form control (field). Control is a technical term that refers to the various elements (buttons, check boxes, radio buttons, text areas) that can be used inside a form to gather information.
The four tags that can be used to build a
form
are:
button
input
select
textarea
The
textarea
control should be used when the user needs to input more than one line of data. If you only expect the user to input a few words, you should use the
input
tag with
type="text"
control that creates a one-line text input window.
Any text or HTML code that occurs between the opening and closing
textarea
tags will appear inside the textarea window.
The separate closing tag is mandatory.
Attributes and Events
class
dir
id
lang
onclick
ondblclick
onkeydown
onkeypress
onkeyup
onmousedown
onmousemove
onmouseout
onmouseover
onmouseup
style
title
accesskey
The
accesskey
attribute allows you to designate a key on the keyboard that when pressed, along with the alt or meta key, will bring focus to the
textarea
element. This attribute is poorly supported.
cols
The
cols
attribute sets how many characters will be visible across the width of the
textbox
window.
disabled
The
disabled
attribute is a Boolean value that, if present, prevents the form control (field) from functioning. In some browsers, the control (field) will appear to be greyed out.
name
The
name
attribute is a string of characters that is used to label a form control (field) with a name. The name must be unique to that document and cannot be reused.
onblur
The
onblur
event allows the execution of JavaScript code when an element loses focus (for example, the mouse was clicked onto another element or a tab navigation directed the cursor elsewhere).
onchange
The
onchange
event allows the execution of JavaScript code when the form field or element has been changed and loses focus.
onfocus
The
onfocus
event allows the execution of JavaScript code when an element comes into focus (for example, the mouse was clicked onto the element or a tab navigation brought the cursor to the element).
onselect
The
onselect
event allows the execution of JavaScript code when the form field or element gains focus.
readonly
The
readonly
attribute allows you to display a text or value in a form control (field) that cannot be changed by the user.
rows
The
rows
attribute sets how many rows will be displayed in the
textarea
window.
tabindex
The
tabindex
attribute specifies an integer that defines the rank in the tabbing order for the specified element when you use the keyboard to navigate (tab through) a page. This attribute is poorly supported.
This example shows two
textarea
windows, the first is not sized and the second is sized.
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="eng">
<head>
<title>DevGuru XHTML textarea Tag Example</title>
</head>
<body>
<form action="html_textarea.html" method="post">
<
textarea name="textarea12"
>
The default size is 2 rows, 20 columns
<
/textarea
>
<br />
<
textarea cols="45" rows="4" name="textarea13
>
This is 4 rows, 45 columns
<
/textarea
>
</form>
</body>
</html>
Output:
The default size is 2 rows, 20 columns
This is 4 rows, 45 columns
Copyright 1999-2001 by Infinite Software Solutions, Inc. All rights reserved.
Trademark Information