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>
	  <title>Radio Button Controls</title>
      <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 />
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 :