HTML radio buttons in forms: production-ready guide
Radio buttons are the right control when a visitor must choose exactly one option from a short list. They work well for plan selection, contact preferences, budget ranges, yes/no questions, and survey answers.
The common mistake is treating radio buttons as small visual widgets instead of form data. A production radio group needs a clear question, accessible labels, stable name and value attributes, validation, and a backend that receives the selected value cleanly.
Basic radio button form
Use the same name for every option in the group. Use a different value for each option.
<form action="https://api.formsfort.com/submit" method="POST"> <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY" />
<fieldset> <legend>Preferred contact method</legend>
<label> <input type="radio" name="contact_method" value="email" required /> Email </label>
<label> <input type="radio" name="contact_method" value="phone" /> Phone </label>
<label> <input type="radio" name="contact_method" value="text" /> Text message </label> </fieldset>
<input type="checkbox" name="botcheck" style="display:none" /> <button type="submit">Send preference</button></form>If the visitor selects “Email”, the backend receives:
contact_method=emailThat is the entire point of a radio group: one field name, one selected value.
Radio buttons vs checkboxes vs select dropdowns
Choose the input based on the decision you are asking the visitor to make.
| Control | Best for | Avoid when |
|---|---|---|
| Radio buttons | One choice from 2-5 visible options | The list is long |
| Checkboxes | Multiple independent choices | Only one answer is allowed |
| Select dropdown | One choice from many options | The options must be compared at a glance |
Radio buttons are usually better than a dropdown when the options are few. Visitors can scan all choices without opening a menu.
Use fieldset and legend for accessibility
Labels identify individual options. A legend identifies the question the options answer.
<fieldset> <legend>Which plan are you interested in?</legend> <label><input type="radio" name="plan" value="free" required /> Free</label> <label><input type="radio" name="plan" value="pro" /> Pro</label> <label><input type="radio" name="plan" value="business" /> Business</label></fieldset>This structure helps screen reader users understand that “Free”, “Pro”, and “Business” are all answers to the same plan question.
Required radio groups
To require an answer, add required to one radio input in the group. You can add it to every option, but one is enough because the browser validates the group by name.
<label> <input type="radio" name="budget" value="under-1000" required /> Under $1,000</label><label> <input type="radio" name="budget" value="1000-5000" /> $1,000 to $5,000</label>Do not rely only on client-side validation. Your form backend should also accept only expected values when the field controls important routing or business logic.
Default selections
Use a default selection only when it is genuinely safe.
<label> <input type="radio" name="newsletter_frequency" value="weekly" checked /> Weekly</label><label> <input type="radio" name="newsletter_frequency" value="monthly" /> Monthly</label>A default can reduce friction for harmless preferences. Avoid defaults for consent, pricing intent, donations, surveys, or anything where preselecting an answer may bias the response.
Styling radio buttons without breaking them
Keep the native input in the DOM and keep the label clickable. This gives you keyboard support and screen reader support without custom JavaScript.
<fieldset class="radio-cards"> <legend>Project type</legend>
<label> <input type="radio" name="project_type" value="website" required /> <span>Website</span> </label>
<label> <input type="radio" name="project_type" value="saas" /> <span>SaaS app</span> </label></fieldset>.radio-cards { display: grid; gap: 12px; border: 0; padding: 0;}
.radio-cards label { display: flex; align-items: center; gap: 10px; border: 1px solid #d6d3d1; border-radius: 8px; padding: 12px; cursor: pointer;}
.radio-cards label:has(input:checked) { border-color: #059669; background: #ecfdf5;}Complete example with a hosted form backend
<form action="https://api.formsfort.com/submit" method="POST"> <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY" /> <input type="hidden" name="subject" value="New project inquiry" />
<label for="email">Email</label> <input type="email" id="email" name="email" required />
<fieldset> <legend>What do you need?</legend> <label><input type="radio" name="need" value="website" required /> Website</label> <label><input type="radio" name="need" value="automation" /> Automation</label> <label><input type="radio" name="need" value="support" /> Support</label> </fieldset>
<fieldset> <legend>Budget range</legend> <label><input type="radio" name="budget" value="under-1000" required /> Under $1,000</label> <label><input type="radio" name="budget" value="1000-5000" /> $1,000 to $5,000</label> <label><input type="radio" name="budget" value="5000-plus" /> $5,000+</label> </fieldset>
<textarea name="message" rows="5" placeholder="Add context"></textarea> <input type="checkbox" name="botcheck" style="display:none" />
<button type="submit">Send inquiry</button></form>This version gives the backend normalized values, gives users readable labels, and keeps the form usable without JavaScript.
Related guides
For a broader starting point, see the HTML form examples page. If you need multi-line responses, use the HTML textarea guide. For general validation patterns, read the HTML form validation guide.
Frequently asked questions
How do I group radio buttons in HTML?
Give every option in the same choice group the same name attribute. The browser then allows only one selected value for that field.
Do radio buttons need a value attribute?
Yes. The value attribute is what your form backend receives when that radio option is selected. Without a value, the submitted data is harder to understand.
How do I make a radio group required?
Add required to at least one radio input in the group. The browser will require the visitor to choose one option before submitting.
Should radio buttons use fieldset and legend?
Yes for most grouped choices. Fieldset and legend give screen readers the question context before each radio option.
Get started free
Ready to add forms to your static site?
No backend required. Point your HTML form at FormsFort and start receiving submissions in minutes.