Open In App

HTML | <input type=”checkbox”>

The HTML <input type=”checkbox”> is used to define a checkbox field. The checkbox is shown as a square box that is ticked when it is activated. It allows the user to select one or more option among all the limited choices. 

Syntax: 



<input type="checkbox"> 

Example: 




<!DOCTYPE html>
<html>
 
<head>
    <title>
        Input type = "checkbox"
    </title>
</head>
 
<body style="text-align: center;">
 
    <h1 style="color:green;">
            GeeksforGeeks
        </h1>
 
    <h2>&lt;input type="checkbox"&gt;</h2>
 
    <form>
 
        <!-- Below input elements have attribute
                checked -->
        <input type="checkbox"
               name="check"
               id="GFG"
               value="1"
               checked>
      Checked by default
        <br>
        <input type="checkbox"
               name="check"
               value="2">
      Not checked by default
        <br>
    </form>
    <br>
 </body>
 
</html>

Output:



  

Supported Browsers:


Article Tags :