label

FilterElements

<label> ... </label>

Used to attach information to form controls (button input, keygen, meter, output, progress, select, and textarea). Each label element is associated with exactly one control. The label element may contain the form control, or it may use the for attribute to identify the control by its id value.

Notes

In HTML5, a label may both contain the control and use the for/id method.

Start/End Tags

Required/Required

Specifications

  • HTML 4.01
  • HTML5

for=

Values: text
Explicitly associates the label with the control by matching the value of the for attribute with the value of the id attribute within the control element.

form=

Values: id of the form owner
HTML5 only. Explicitly associates the label element with its associated form (its form owner). With this method, the label does not need to be the child of the applicable form element.

Form control and its labeling text contained within the label element:

<label>Last Name: <input type"text" size="32"></label>

Using the for/id method to associate the form control with its labeling text:

<label for="lastname">Last Name:</label>
<input type="text" id="lastname" size="32">

Rendered Example


Both methods result in the rendering shown here.