HTML Form How to - Make the checkbox selected when click the label








Question

We would like to know how to make the checkbox selected when click the label.

Answer


<!DOCTYPE html>
<html>
<body>
  <input id="thisinput" type="checkbox" />
  <label for="thisinput">I agree</label>
</body>
</html>

The code above is rendered as follows: