How to create an HTML checkbox with a clickable label?
To make an HTML checkbox with a clickable label means the checkbox gets on/off when the label is clicked.
Below are the methods:
- Using checkbox inside label tag:
<!DOCTYPE html><html><head><title>Create an HTML checkbox with a clickable label</title><!-- Adding Style to label --><style>.GFG {background-color: white;border: 2px solid black;color: green;padding: 5px 10px;text-align: center;display: inline-block;font-size: 20px;margin: 10px 10px;cursor: pointer;}</style></head><body><h1>GeeksforGeeks</h1><!-- Putting checkbox inside label tag --><labelclass="GFG"><inputtype="checkbox"name="checkbox"value="Geeks">GFG</label></body></html>chevron_rightfilter_noneOutput:
Before clicking the label:

After clicking the label:
- Using the for attribute: Create a checkbox using input tag then create a label for the created checkbox using the for attribute.
<!DOCTYPE html><html><head><title>Create an HTML checkboxwith a clickable label</title><!-- Adding Style to label --><style>.GFG {background-color: white;border: 2px solid black;color: green;padding: 5px 10px;text-align: center;display: inline-block;font-size: 20px;margin: 10px 10px;cursor: pointer;}</style></head><body><h1>GeeksforGeeks</h1><!-- Using the for attribute in label --><inputtype="checkbox"name="checkbox"id="checkID"value="Geeks"><labelclass="GFG"for="checkID">GFG</label></body></html>chevron_rightfilter_noneOutput:
Before clicking the label:

After clicking the label:

Recommended Posts:
- HTML | label Tag
- HTML | label Attribute
- HTML <label> for Attribute
- HTML | DOM Label Object
- How to set checkbox size in HTML/CSS?
- HTML | DOM Option label Property
- HTML | <optgroup> label Attribute
- HTML | <track> label Attribute
- HTML | DOM Track label property
- HTML | <label> form Attribute
- HTML | DOM Label htmlFor Property
- HTML | DOM OptionGroup label Property
- HTML | aria-label attribute
- HTML | <option> label Attribute
- HTML | DOM Input Checkbox name Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



