HTML <label> tag

Usage

Defines a label for an element such as a radio button or checkbox. The difference between a label and the normal text next to an input is that with a label the option will be toggled when the user clicks on the label, rather than just when they click the option itself.

Example

Code:

<input type="radio" id="normal" name="labeltest">Normal radio button</input><br />
<input type="radio" id="withlabel" name="labeltest"/>
<label for="withlabel">With label, try clicking the label text</label>

Output:

Normal radio button

Required Attributes

  • none

Optional Attributes

  • for - specifies the id of the option that the label should be associated with

Core Attributes