Radio Button Control in HTML

Radio buttons let a user select ONE of a limited number of choices. Radio buttons are used when out of many options, just one option is required to be selected. Radio buttons are created using an <input> element whose type attribute has a value of radio. Example :
<!DOCTYPE html>
<html>
   <head>
	  <title>Radio Button Controls</title>
   </head>
   <body>
      <form action="login_page.php" method="post">
	Select Gender : <br /><br />
	<input type="radio" name="gender" value="male"> Male <br />
	<input type="radio" name="gender" value="female" /> Female <br />
	<input type="radio" name="gender" value="other" /> Other <br />
      </form>
   </body>
</html>
The output of above code will be :


Attributes :

The attributes used in the radio button control are as follows :

  • type : Indicates the type of input control and for checkbox input control it will be set to radio.
  • name : Used to give a name to the control which is sent to the server to be recognized and get the value.
  • value : The value that will be used if the radio box is selected.
  • checked : Set to checked if you want to select it by default.



Next Topic :