Categories
Web development

HTML Checkbox

The checkbox is shown as a square box that is ticked (checked) when activated. Using checkboxes is a good option when you want to give your website visitors the option to choose one or more options of a limited number of choices.

HTML Checkbox

The CSS <input type=”checkbox”> specifies a checkbox.

Syntax:

<input type="checkbox">

Example:

<!DOCTYPE html>
<html>
<body>
<div><h3>How many cats do you have?</h3><br>
  <input type="checkbox" id="one" name="one" value="one">
  <label for="one"> One</label><br>   
  <input type="checkbox" id="two" name="two" value="two">
  <label for="two"> Two</label><br>     
  <input type="checkbox" id="three" name="three" value="three">
  <label for="three"> Three</label><br>
  <input type="checkbox" id="other" name="other" value="other">
  <label for="other"> Other</label><br>
 
</div>
</body>
</html>

Note: Always add the <label> tag.

Output:

How many cats do you have?






Click here to see how to style the HTML Checkbox using CSS.

Enjoy coding!

Read also:

HTML Radio Buttons

How to create a custom checkbox and radio button with CSS?

CSS Toggle Switch