HTML Dog
Skip to navigation

HTML Tag: label

A label, or caption, for a form control.

A label can be associated to a form control either by nesting the control within it or by matching the value of the label’s for attribute to the value of a control’s id attribute.

“Labelable elements”, that is, elements that can be associated with labels, are input (expect for the hidden type), textarea, select, button, keygen, meter, output, and progress.

Optional Attributes

Attribute Description Possible values
for Associates the label with a form control. Text matching the value of a form control’s id attribute.
form Explicitly associates the label to a form element, which it may or may not be nested within. If absent, the label will be associated to its form ancestor. Text matching the value of a form element’s id attribute.
Global attributes

Example


<label for="emailadd">Email address: </label><input type="email" name="emailadd" id="emailadd">

<!-- or... -->

<label>Email address: <input type="email" name="emailadd"></label>