Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
How to add a checkbox in forms using HTML?
The checkbox is one of the characteristics of the HTML input tag. They display as square boxes that the front-end user can dynamically check off. When we want the user to offer a variety of inputs, the HTML checkbox comes in handy. Users choose the items they wish from the entire list when presented with a checkbox enquiry by checking or ticking these text boxes. The data from the checked checkboxes is gathered and stored in the background when the form is submitted.
Typically, a checkbox can be in one of three states: checked, unchecked, or indeterminate. When a user has the option of selecting many options, it is necessary on forms. Before we dive into the article let?s have a quick view on the HTML .
HTML
A checkbox field is created using the HTML tag. The checkbox is displayed as a square box that is checked when it is active. The user is given the option of choosing one or more options from the few available options.
Syntax
Following is the syntax for HTML checkbox tag
Example
In the following example, we are going to create a simple checkbox form using HTML.
HTML CheckBox
When we run the above code, it will generate an output consisting of the option provided with checkboxes displayed on the webpage, allowing the user to select the option and submit the form.
Example
Let?s look at the following example, where we are going to set the default value for the checkbox in the form.
On running the above code, the output window will pop up, displaying the checkboxes, out of which one is checked by default, displayed on the webpage, along with a submit button.
Example
Considering another scenario where we are going to disable the checkbox in the form.
HTML disabled CheckBox
When we run the above code, it will generate an output consisting of the disabled checkbox displayed on the webpage along with a submit button.
