Tag Description
The label tag is used to define a label for an input element.
This tag has the form:
<label for="element_id">
</label>
HTML5 and HTML4.01 Differences
HTML5 defines a new attribute.
HTML5 | = New for HTML5 |
Attributes
Attribute | Value | Description |
---|---|---|
for | element_id | Specifies which form element this label is bound to |
formHTML5 | form_id | Defines one ore more forms the field belongs to |
Global Attributes
This tag also supports the HTML Global Attributes.
Event Attributes
This tag also supports the HTML Event Attributes.
Examples
The following example shows the basic use of this tag:
<form>
<label for="male">
Male
</label>
<input type="radio" name="sex" id="male" />
<label for="female">
Female
</label>
<input type="radio" name="sex" id="female" />
</form>
This produces the following result:
Browser Support
Chrome | Firefox | IE | Safari | Opera |
---|---|---|---|---|
Doctype Declaration Support
The following table lists the doctype declarations this element may appear in:
HTML4.01 / XHTML1.0 | XHTML 1.1 | HTML 5 | ||
---|---|---|---|---|
Traditional | Strict | Frameset | ||
Miscellaneous Information
Defined In: | HTML4 |
---|---|
Empty Tag: | No |