From http://www.w3schools.com (Copyright Refsnes Data)

HTML 5 <label> tag


Definition and Usage

Defines a label to a control. If you click the text within the label element,  it is supposed to toggle the control.


Differences Between HTML 4.01 and HTML 5

NONE


Tips and Notes

Note: The "for" attribute binds a label to another element. Set the value of the "for" attribute equal to the value of the "id" attribute of the related element.


Example

Source Output

<p>Try clicking on the text labels:</p>

<form name="input" action="">
<input type="radio" name="sex" id="male" />
<label for="male">Male</label>
<br />
<input type="radio" name="sex" id="female" />
<label for="female">Female</label>
</form>

Try clicking on the text labels:




Attributes

Attribute Value Description 4 5
for id_of_another_field Defines which form element the label is for. Set to an ID of a form element.

Note: If this attribute is not specified, the label is associated with its contents.

4 5

Standard Attributes

class, contenteditable, contextmenu, dir, draggable, id, irrelevant, lang, ref, registrationmark, tabindex, template, title

For a full description, go to Standard Attributes in HTML 5.

Event Attributes

onabort, onbeforeunload, onblur, onchange, onclick, oncontextmenu, ondblclick, ondrag, ondragend, ondragenter, ondragleave, ondragover, ondragstart, ondrop, onerror, onfocus, onkeydown, onkeypress, onkeyup, onload, onmessage, onmousedown, onmousemove, onmouseover, onmouseout, onmouseup, onmousewheel, onresize, onscroll, onselect, onsubmit, onunload

For a full description, go to Event Attributes in HTML 5.


Try-It-Yourself Demos

Label
How to define a label to a control.


From http://www.w3schools.com (Copyright Refsnes Data)