Radio button

It is generally used in HTML forms. HTML forms are required when you need to collect some data from site visitors. A radio button is used when you want to select only one option out of several available options.

Example 1: In this example, we will see the use of radio buttons with an example.

html




<!DOCTYPE html>
<html lang="en">
 
<head>
    <title>GeeksfoGeeks</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:

Radio Button Vs Checkbox in HTML

Radio buttons allow users to select only one option from a group, while checkboxes permit multiple selections. Use radio buttons when exclusive choices are needed, and checkboxes for multiple independent choices.

Table of Content

  • Radio button
  • Checkbox

Similar Reads

Radio button:

It is generally used in HTML forms. HTML forms are required when you need to collect some data from site visitors. A radio button is used when you want to select only one option out of several available options....

Checkbox:

...

Difference between radio button and 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....

Contact Us