O'Reilly logo

Dynamic HTML: The Definitive Reference by Danny Goodman

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Name

<LABEL> — NN n/a IE 4 HTML 4

Synopsis

<LABEL>...</LABEL>

End Tag: Required

The LABEL element defines a structure and container for the label associated with an INPUT element. Because the rendered labels for most form controls are not part of the element’s tag, the LABEL attribute provides a way for a browser to clearly link label content to the control.

You have two ways to provide the association. One is to assign the ID attribute value of the control to the FOR attribute of the LABEL element. The other is to wrap the INPUT element inside a LABEL element. The latter is possible only if the label and control are part of running body content; if you must physically separate the label from the control because they exist inside separate TD elements of a table, you must use the FOR attribute linkage. Whether the label is rendered in front of or after the control depends entirely on the relative locations of the tags in the source code. A future application for this element is for text-to-speech browsers reading aloud the label for a control.

Example

<FORM>
<LABEL>Company:<INPUT TYPE="text" NAME="company"></LABEL><BR>
<LABEL FOR="stateEntry">State:</LABEL>
<INPUT TYPE="text" NAME="state" ID="stateEntry">
...
</FORM>

Object Model Reference

IE

[window.]document.all.elementID

Attributes

ACCESSKEY

DATAFORMATAS

FOR

LANGUAGE

TABINDEX

CLASS

DATASRC

ID

STYLE

TITLE

DATAFLD

DIR

LANG

  

Event Handler Attributes

Handler

NN

IE

HTML

onBlur

n/a

n/a

4

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required