HTML <input type="checkbox">

Last Updated : 23 May, 2026

The <input type="checkbox"> element in HTML is used to create checkboxes for selecting one or more options. Unlike radio buttons, multiple checkboxes can be selected at the same time.

  • Used to select multiple options from a list.
  • Each checkbox can be checked or unchecked independently.
  • Commonly used in forms, preferences, and option selections.

Syntax:

<input type="checkbox"> 

Example: Demonstrate using the HTML <input type="checkbox"> element.

html
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>

<head>
    <title>
        HTML Input Type Checkbox
    </title>

    <style>
        h2 {
            text-align: center;
        }

        fieldset {
            width: 250px;
            margin: auto;
        }
    </style>
</head>

<!--Driver Code Ends-->

<body>
    <h2>HTML &lt;input type="checkbox"&gt;</h2>

    <form action="#">
        <fieldset>
            <legend>Select Your Subjects:</legend>

            <input type="checkbox" 
                   name="check" 
                   id="checkbox1" 
                   value="html" checked>
            <label for="checkbox1">HTML</label>
            <br>

            <input type="checkbox" 
                   name="check" 
                   id="checkbox2" 
                   value="css">
            <label for="checkbox2">CSS</label>
            <br>

            <input type="checkbox" 
                   name="check" 
                   id="checkbox3" 
                   value="javascript">
            <label for="checkbox3">JavaScript</label>
        </fieldset>
    </form>
</body>

<!--Driver Code Starts-->

</html>

<!--Driver Code Ends-->
Comment