How to Make Radio Buttons in HTML
Radio buttons let people pick exactly one option from a short list. Give every <input type="radio"> in the list the same name and its own value, and the browser makes sure only one of them is selected at a time.
Syntax
<label><input type="radio" name="<group>" value="<value>"> <text></label>
<label><input type="radio" name="<group>" value="<value>" checked> <text></label>
| Part | What it does |
|---|---|
type="radio" | Makes the input a radio button. |
name="<group>" | The group's name. Radio buttons with the same name form one group, and only one in it can be selected. The form also sends the choice under this name. |
value="<value>" | What the form sends when this radio button is selected. |
checked | Optional. Selects this radio button when the page opens. |
<text> | The words next to the radio button. Inside the same label as the input, clicking them selects it too. |
MDN's input type="radio" page covers every attribute.
The Example
The example is a small order form with three sizes, Small, Medium and Large, where Medium is selected from the start, and an Order button.
Step 1: Write the Code
Create a file named index.html in a text editor, such as Visual Studio Code:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Radio buttons</title>
</head>
<body>
<form>
<p>Choose a size:</p>
<label><input type="radio" name="size" value="small"> Small</label>
<label><input type="radio" name="size" value="medium" checked> Medium</label>
<label><input type="radio" name="size" value="large"> Large</label>
<p><button type="submit">Order</button></p>
</form>
</body>
</html>
Step 2: Choose Large
Double-click index.html to open it in your browser. Medium is selected, because it has checked. Click Large:

Medium was unselected by itself when you chose Large. The screenshot comes from Chromium 159, the open-source browser that Chrome is built on.
Step 3: Send the Form
Click Order. The page loads again, and the address now ends with index.html?size=large.
What Happened
- The three radio buttons are one group, because they share
name="size", so selecting Large unselected Medium. - The form sent only the selected option: the group's
name,size, with the selected button'svalue,large. - Clicking Large a second time didn't unselect it. A selected radio button stays selected until another one in its group is chosen.
Common Mistakes
| Mistake | What happens | Do this instead |
|---|---|---|
Giving the radio buttons different names | They're no longer one group: with Large renamed to name="sizes", Small and Large could both be selected | Give every radio button in the group the same name |
Leaving out value | The form sends on instead of the option: with no value on Large, the address ended with ?size=on | Give each radio button its own value |
| Using radio buttons when people may choose several options | Only one can ever be selected | Use checkboxes |
Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| Two radio buttons are selected at once | Their names differ | Use the same name |
The form sends on | The selected radio button has no value | Add a value |
| Clicking the words doesn't select the option | The words aren't in a label with the input | Wrap the input and its words in one label |
FAQ
How do people clear their choice?
They can't, by clicking it again. If people must be able to choose nothing, add an option for that, such as None.
Can people choose with the keyboard?
Yes. With Medium selected and focused, pressing the Down arrow key selected Large.
How do I start with no option selected?
Leave checked off every radio button in the group.
Conclusion
Give the radio buttons in a group the same name and each its own value, mark one with checked if you want a default, and the browser does the rest: one choice at a time, sent as name=value.
Additional Resources
- input type="radio", on MDN.
