HTML radio button

What Is an HTML Radio Button and How Is It Used?

It creates radio buttons. When you required getting input only one option out of many option, so for it you can set type attribute as radio. Example


<form method="post" name="frmCheckbox">
   Which sport you like?
   <input type="radio" name="color" value="Red"> Red
   <input type="radio" name="color" value="Blue"> Blue
   <input type="radio" name="color" value="Green"> Green
   <input type="radio" name="color" value="Yellow"> Yellow
   <input type="radio" name="color" value="Black"> Black
   <input type="radio" name="color" value="White"> White
   <input type="submit" name="save" value="Save">
</form>
You should provide same name to a group of radio button, so it would belong to a group. Output

   Which sport you like?
    Red
    Blue
    Green
    Yellow
    Black
    White
   

FAQ 1. Can Users Change Their Radio Button Selection? Yes, users can change their selection by clicking another radio button in the same group. When a different option is selected, the previously selected radio button is automatically deselected. 2. How Can I Make an HTML Radio Button Required? You can use the required attribute to make selecting an option mandatory. At least one radio button in the same group must be selected before normal form submission can proceed. 3. What Is the Purpose of the Value Attribute in an HTML Radio Button? The value attribute specifies the data submitted when a radio button is selected. For example, if a user selects a radio button with value="male", that value is included in the submitted form data.