Open In App

How to add Radio Buttons in form using HTML ?

Last Updated : 15 May, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will learn how to add Radio Buttons in form using HTML. We know that Radio Buttons are used to select only one option out of several options. It is generally used in HTML form. If we want to deselect any option we have to select another option in the case of a radio button.

Approach: To add a radio buttons in a webpage, the HTML provides a <input> element with type attribute is set to “radio”.  

Syntax:

<input type="radio">  

Example: Below code illustrates that how to add a radio button in the webpage. 

HTML




<!DOCTYPE html>
<html>
  
<head>
          
    <style>
        body {
            text-align: center;
        }
        h2 {
            color: green;
             
        }
    </style>
</head>
  
<body>
    <h2>
        GeeksforGeeks
    </h2>
  
    <h3>
        How to add a Radio Buttons in form using HTML?
    </h3>
    <h4>
    Select Gender
    </h4>
      
    Male
    <input type="radio" checked=true name="user_gender">
    Female
    <input type="radio"  name="user_gender">     
        
</body>
  
</html>                    


Output:

gender of user



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads