Specifies a label for another element on the page.
HTML Syntax
<LABEL ACCESSKEY=key CLASS=classname DATAFLD=colname DATAFORMATAS=HTML | TEXT DATASRC=#ID FOR=ID ID=value LANG=language LANGUAGE=JAVASCRIPT | JSCRIPT | VBSCRIPT | VBS STYLE=css1-properties TITLE=text event = script >
Remarks
To bind LABEL to another control, set the FOR attribute of the LABEL element equal to the ID of the control. Binding LABEL to the NAME attribute of the control has no effect. However, to submit a form, you must specify a NAME on the control to which the LABEL element is being bound.
There are two ways to underline the designated access key. The rich text support in the LABEL object makes it possible to wrap the U element around the character in the label text specified by the accessKey property. If you prefer to use cascading style sheets (CSS) to apply style formatting, enclose the designated character in a SPAN and set the style to "text-decoration: underline".
If the user clicks the label, the onclick event goes to the label and then bubbles to the control specified by the htmlFor property. Pressing the access key for the label is the same as clicking the label.
The LABEL element is an inline element and requires a closing tag. Labels cannot be nested.
This element is available in HTML and script as of Microsoft® Internet Explorer 4.0.
Members
Styles
Example
This example uses the LABEL object and the accessKey property to set focus on a text box.
Sample Code
<LABEL FOR="oCtrlID" ACCESSKEY="1"> #<U>1</U>: Press Alt+1 to set focus to textbox </LABEL> <INPUT TYPE="text" NAME="TXT1" VALUE="binding sample 1" SIZE="20" TABINDEX="1" ID="oCtrlID">