Radio Button vs Checkbox vs Select in HTML

Radio buttons, checkboxes and <select> lists all let users choose from predefined options, but they solve different problems. Use radio buttons for one choice from a small visible set, checkboxes for independent choices where several may be selected, and a select list when a longer list needs to fit into less space.

A normal <select> allows one selected option. Add the multiple attribute only when the form genuinely needs multiple values.

Quick Comparison Top ↑

Comparison of radio buttons, checkboxes and select controls
ControlTypical selectionBest use
Radio buttonsOne option from a groupSmall set of mutually exclusive choices
CheckboxesZero, one or several optionsIndependent choices or preferences
Select listOne by default; several with multipleLonger lists where compact presentation is useful

Working Examples Top ↑

Radio buttons
Checkboxes

Radio Buttons: One Choice from a Group Top ↑

Radio buttons are mutually exclusive when the controls share the same name. Each radio button should still have its own unique id so its label can identify it.

<fieldset>
  <legend>Delivery method</legend>
  <input type="radio" name="delivery" id="standard" value="standard">
  <label for="standard">Standard</label>

  <input type="radio" name="delivery" id="express" value="express">
  <label for="express">Express</label>
</fieldset>

If express is chosen, the submitted pair is typically delivery=express.

Checkboxes: Independent Choices Top ↑

Checkboxes are appropriate when each option can be selected independently. An unchecked checkbox is normally absent from the submitted form data, so server-side code should not assume every checkbox name will be present.

<fieldset>
  <legend>Topics</legend>
  <input type="checkbox" name="topics[]" id="html" value="html">
  <label for="html">HTML</label>

  <input type="checkbox" name="topics[]" id="css" value="css">
  <label for="css">CSS</label>
</fieldset>

The bracketed name topics[] is useful when the receiving PHP page expects multiple submitted values under one logical field name.

Select List: Compact Choice Top ↑

A standard select control submits the value of its selected <option>. Use a visible <label>; the first option can act as a prompt when it has an empty value.

<label for="city">City</label>
<select name="city" id="city">
  <option value="">Choose a city</option>
  <option value="hyderabad">Hyderabad</option>
  <option value="mumbai">Mumbai</option>
</select>

Setting a Default Option Top ↑

Add selected to the option that should initially be selected.

<option value="mumbai" selected>Mumbai</option>

Selecting More Than One Option Top ↑

Add multiple when several values may be selected. On desktop systems, selecting several items may require keyboard modifiers, so for a small set of choices checkboxes can be easier to discover and use.

<label for="skills">Skills</label>
<select name="skills[]" id="skills" multiple>
  <option value="html">HTML</option>
  <option value="css">CSS</option>
  <option value="javascript">JavaScript</option>
</select>

Which Selection Control Should You Use? Top ↑

  • Use radio buttons when one answer must be chosen from a small set and users benefit from seeing every option immediately.
  • Use checkboxes when each choice is independent and users may select any number of options.
  • Use a select list when one choice comes from a longer list and compact presentation is useful.
  • Use a multiple select carefully. For a modest number of multi-choice options, checkboxes are often easier to understand.

What Gets Submitted? Top ↑

For all three control types, the browser submits the control's name together with the selected value. Controls generally need a name to participate in form submission.

Validate on the server. A browser can be modified and submitted values can be changed manually. Radio, checkbox and select choices should be checked against the allowed values on the receiving server.

Accessibility and Usability Top ↑

  • Associate every control with a visible <label>.
  • Use <fieldset> and <legend> for a related group of radio buttons or checkboxes.
  • Do not use placeholder-like option text as the only explanation of what a select control means; provide a real label.
  • Keep radio and checkbox labels clickable by connecting for to a unique control id.
  • Do not disable options merely to hide business rules; server-side validation is still required.
Different types of user selection options and their difference: where to use which type

Common Mistakes Top ↑

Giving every radio button a different name Top ↑

Radio buttons are mutually exclusive only when the group uses the same name.

Assuming unchecked checkboxes submit false Top ↑

Unchecked checkboxes are normally omitted from form submission, so handle the missing value correctly on the server.

Assuming every select allows multiple choices Top ↑

A normal select is single-choice. Multiple selection requires the multiple attribute.

Using id and name as if they do the same job Top ↑

id connects labels, scripts and page references to one element. name identifies the submitted form field.

Trusting submitted option values Top ↑

Users can alter submitted values. Validate selected values against an allowlist on the server.

Frequently Asked Questions Top ↑

Q1: What is the difference between a radio button and a checkbox?

Radio buttons are normally used when one choice must be selected from a group. Checkboxes represent independent choices, so zero, one or several may be selected.

Q2: Can an HTML select allow more than one option?

Yes. A select is single-choice by default. Add the multiple attribute when users should be able to select several options.

Q3: Why must radio buttons in one group use the same name?

The shared name makes the controls one mutually exclusive radio group and identifies the field submitted with the selected value.

Q4: Are unchecked checkboxes submitted?

Normally no. An unchecked checkbox is absent from the submitted form data, so the receiving code should handle that case.

Q5: What is the difference between id and name on a form control?

The id identifies an element in the page and connects it with a label. The name identifies the field in submitted form data.

Q6: Should submitted radio, checkbox or select values be trusted?

No. Client-side controls can be modified, so the server should validate submitted values against the values it allows.


HTML Form Checkbox in a form Radio button in a form Drop down List box
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
©2000-2026   plus2net.com   All rights reserved worldwide Privacy Policy Disclaimer