

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do we use checkbox buttons in HTML forms?
Using HTML forms, you can easily take user input. The <form> tag is used to get user input, by adding the form elements. Different types of form elements include text input, radio button input, submit button, etc.
Let’s learn about how to use radio checkbox in HTML forms to get user input. Checkboxes are used when more than one option is required to be selected. They are also created using HTML <input> tag but type attribute is set to a checkbox.
Here are the attributes −
Sr.No | Attribute & Description |
1 | type Indicates the type of input control and for checkbox input control it will be set to a checkbox. |
2 | name Used to give a name to the control which is sent to the server to be recognized and get the value. |
3 | value The value that will be used if the checkbox is selected |
4 | checked Set to checked if you want to select it by default |
Example
You can try to run the following code to learn how to work with checkbox buttons in HTML −
<!DOCTYPE html> <html> <body> <head> <title>HTML Checkbox Button</title> </head> <p>Which languages you work on:</p> <form> <input type="checkbox" name="language1" value="java">Java <br> <input type="checkbox" name="language2" value="php">PHP <br> <input type="checkbox" name="language3" value="cpp">C++ <br> </form> </body> </html>
- Related Questions & Answers
- How do we use radio buttons in HTML forms?
- Why do we use reset button in HTML forms?
- How do we take password input in HTML forms?
- How do we send an email using HTML forms?
- How do we use a simple drop-down list of items in HTML forms?
- How do we reset all the input fields in HTML forms?
- How do we upload external file on a website using HTML forms?
- How we can group data in HTML forms?
- How do we use different CSS classes in HTML?
- How to use the submit button in HTML forms?
- Why do we use DOCTYPES in HTML document?
- What HTML forms are and how to use them?
- Why do we use head tag in HTML Page?
- Why do we use the novalidate attribute in HTML?
- How to use checkbox in Android?
Advertisements