Radio button

Updated: 11/13/2018 by Computer Hope
Radio button

A radio button is one type of selection indicator in a list of options. If an option is selected, the circle is filled. If the option is not selected, the circle is empty. When one circle is selected, the others are deselected so that only one option may be selected at any time.

Radio button example

Below is an example of what the radio button looks like in your browser.

Example 1.
Example 2.
Example 3.
Example 4.
Example 5.

In our example, you can see only one radio button can be selected.

How to create a radio button on my HTML web page

To create a radio button on an HTML (hypertext markup language) page, use the <input> tag as shown below. In the example below, we use the code from the radio button example to make a radio button followed by the "Example 1" text.

<input name="example" type="radio" value="V1"> Example 1

If you want user input from a radio button, it must be included in a <form> tag. When submitted, it is often sent to a Perl, PHP (PHP: Hypertext Preprocessor), or Python script that performs various actions depending on the selected radio button.

Tip

If you are using multiple radio buttons, and you want only one to be selected at once, give them the same name attribute, but give each a unique value attribute. For example, if we used the above code and wanted to create another radio button, it would still be named "example," but be given a different value.

Note

A radio button can be made to allow the visitor to select multiple radio buttons. However, to prevent any confusion, we always suggest using check boxes and not radio buttons if you want more than one option to be selected.

What is the difference between a check box and a radio button?

A check box is always square and allows one or more items to be selected. A radio button is a circle that only allows one selected item. If you're creating a list that needs multiple options selected, use check boxes. If you want only one option to be selected and prevent multiple options from being selected, use a radio button.

Button, Check box, Push-button, Software terms