Radio button: It is generally used in HTML forms. HTML forms are required when you need to collect some data from the site visitors. A radio button is used when you want to select only one option out of several available options.
Example:
<html> <head> <title> Radio Button <title> </head> <body> <form> Do you agree this statement? <br> <input type="radio" name="agree" value="yes">Yes <br> <input type="radio" name="agree" value="no">No <br> <input type="Submit"> </form> </body> </html> |
Output:

Checkbox: Checkboxes are also mostly used in HTML forms. A checkbox allows you to choose one or many options to be selected from a list of options.
Example:
<html> <head> <title> HTML Checkbox <title> </head> <body> <form> Choose languages you know: <br> <input type="checkbox" name="C" value="yes">C <br> <input type="checkbox" name="C++" value="yes">C++ <br> <input type="checkbox" name="Java" value="yes">Java <br> <input type="checkbox" name="Python" value="yes">Python <br> <input type="Submit"> </form> </body> </html> |
Output:

Difference between radio button and checkbox
| Radio button | Checkbox |
|---|---|
| It is used when only one option to be selected out of several available options. | Checkbox allows one or many options to be selected. |
| It is created by using HTML <input> tag but type attribute is set to radio. | It is also created using HTML <input> tag but type attribute is set to checkbox. |
| It is a single control unit. | It is a multiple control unit. |
| Radio button is presented as a small circle on the screen. | Checkbox is presented as a small square box on the screen. |
| Radio button have only 2 states namely- True & False. | Checkbox have 3 states namely- Checked, unchecked & indeterminate. |
| It is used when you want to limit the users choice to just one option from the range provided. | It is used when you want to allow user to select multiple choices. |
Recommended Posts:
- How to create a radio button similar to toggle button using Bootstrap ?
- How to Create Custom Radio Button using HTML and CSS ?
- How to move button in the same line with Checkbox and Textbox using JavaScript ?
- How to trigger HTML button after hitting enter button in textbox using JavaScript ?
- How to check a radio button with jQuery?
- How to know which radio button is selected using jQuery?
- How to unchecked a radio button using JavaScript/jQuery?
- How to get value of selected radio button using JavaScript?
- How to check whether a radio button is selected with JavaScript ?
- button tag vs input type="button" attribute
- HTML | DOM Input Checkbox disabled Property
- HTML | DOM Input Checkbox Property
- How to set checkbox size in HTML/CSS?
- HTML | DOM Input Checkbox autofocus Property
- HTML | DOM Input Checkbox required Property
- HTML | DOM Input Checkbox name Property
- HTML | DOM Input Checkbox checked Property
- HTML | DOM Input Checkbox value Property
- HTML | DOM Input Checkbox type Property
- HTML | DOM Input Checkbox form Property
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


