The non-nestable LABEL element accomplishes two tasks:
association of a description with a form field control and
increasing the size of the active user interface region for
selecting the form control. Description attachment is of greatest
use to speech-based browsers, while the benefits of an increased
user interface region are felt most by users of browsers that
accommodate a pointing device (such as a mouse or pen.) Activating a
LABEL with a pointing device passes input focus on to its associated
form field control.
Labels are attached either explicitly or implicitly. Explicit
attachment is accomplished through the use of a form field ID as the
value of the FOR attribute. This method allows attachment of a LABEL
to a field elsewhere in the document and has the advantage of
allowing multiple LABELs to be attached to a single form field.
Form fields are attached implicitly to a LABEL when they are in
the contents of the LABEL element. In this case, the LABEL must only
contain one form field within the LABEL contents.
accesskey - This is a method of
giving access/focus to an active HTML element using a keyboard
character. This is a common GUI paradigm also known as a
"keyboard shortcut" or "keyboard accelerator" A
single character is used as the value of this attribute. In
addition, a platform-dependent key is usually used in combination
with the ACCESSKEY character to access the functionality of the
active field.
for - This attribute identifies
which form field the LABEL is attached to. If this attribute is not
used, the LABEL is associated with its contents.
onblur - A blur Event Handler
executes script code when a hyperlink loses focus.
onfocus - A focus Event Handler
executes script code when a hyperlink receives focus by tabbing with
the keyboard or clicking with the mouse.