Warning:
This wiki has been archived and is now read-only.
Elements/label
From HTML Wiki
< Elements
Contents
<label>
The <label> element represents a caption in a user interface.
Point
- The caption can be associated with a specific form control:
- Using for attribute [Example A]
- By putting the form control inside the label element itself. [Example B]
HTML Attributes
form
= string
Associate the fieldset element with its form owner.
for
= string
Specified to indicate a form control with which the caption is to be associated.
The attribute's value must be the ID of a labelable form-associated element in the same Document as the label element.
See also global attributes.
Examples
Example A
Using for attribute [try it]:
<input type="checkbox" id="lost" name="lost"> <label for="lost">Lost</label>
Example B
By putting the form control inside the label element itself [try it]:
<label><input type="checkbox" name="lost"> Lost</label>
HTML Reference
The HTML5 specification defines the <label> element in 4.10.6 The label element.