HTML Radio Button


 
 
 

  HTML Tutorial > HTML Forms > Radio Button

A second type of input is the radio button. Radio buttons are used when you want users to be able to select one and only one of the options. Below is an example:

Code:
<input type="radio" name="color" value="red">Red<br>
<input type="radio" name="color" value="green">Green<br>
<input type="radio" name="color" value="blue">Blue<br>

Red
Green
Blue

In this case, the key is color, and the values can be either red, green, or blue, depending on the radio button selected.

If we want to pre-select a radio button, we'll specify "selected" at the end of the <input> tag, such as follows:

<input type="radio" name="color" value="red" selected>Red<br>

Next: Check box

Site Map   |   Resources

Link to this page: If you find this page useful, we encourage you to link to this page. Simply copy and paste the code below to your website, blog, or profile.





    Copyright 2006, 2007, 2008 1keydata.com     Privacy Policy