Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

  1. Home
  2. HTML Tag Dictionary
  3. <input> — Selection

<input> — Selection

The selection-type input elements let you create form controls that allow users to choose from multiple options. Checkboxes allow multiple selections, while radio buttons allow only one selection at a time.

Syntax

<!-- Checkbox (multiple selections allowed) -->
<input type="checkbox" name="fruit" value="apple"> Apple

<!-- Radio button (only one selection per group with the same name) -->
<input type="radio" name="color" value="red"> Red
<input type="radio" name="color" value="blue"> Blue

<!-- Pre-selected by default -->
<input type="checkbox" name="agree" value="yes" checked> I agree

Attributes

AttributeDescription
type="checkbox"Displays a checkbox. Multiple options can be selected at the same time.
type="radio"Displays a radio button. Only one option can be selected within a group sharing the same name.
nameSpecifies the key name for the form data. Radio buttons with the same name form a group.
valueSpecifies the value sent to the server when the control is selected.
checkedPre-selects the control when the page loads. This is a boolean attribute and requires no value.

Sample Code

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Selection Input</title>
</head>
<body>

  <form>
    <!-- Checkboxes (multiple selections allowed) -->
    <p>Favorite foods (select all that apply):</p>
    <input type="checkbox" name="food" value="sushi"> Sushi
    <input type="checkbox" name="food" value="ramen" checked> Ramen
    <input type="checkbox" name="food" value="tempura"> Tempura

    <!-- Radio buttons (select one only) -->
    <p>Favorite season (select one):</p>
    <input type="radio" name="season" value="spring"> Spring
    <input type="radio" name="season" value="summer" checked> Summer
    <input type="radio" name="season" value="autumn"> Autumn
    <input type="radio" name="season" value="winter"> Winter

    <p><button type="submit">Submit</button></p>
  </form>

</body>
</html>

Result

The checkboxes display with "Ramen" pre-checked, allowing multiple selections. The radio buttons display with "Summer" pre-selected, and only one option can be chosen at a time.

Rendered HTML Preview
Favorite foods (select all that apply): Sushi Ramen Tempura Favorite season (select one): Spring Summer Autumn Winter Submit

Overview

Use checkboxes (type="checkbox") when you want users to independently select multiple items, such as "I agree" or "Receive notifications." Use radio buttons (type="radio") when the choices are mutually exclusive — for example, gender or payment method. It is important that radio buttons in the same group share the same name attribute.

The value attribute holds the value sent to the server on form submission. If you omit value on a checkbox, the string "on" is sent instead — always set an explicit value.

To associate a label with a control, use the label element. Clicking the label also toggles the checkbox or radio button, which increases the clickable area and improves usability.

Browser Compatibility

Chrome Chrome
49+
Supported in all versions
Firefox Firefox
57+
Supported in all versions
Safari Safari
18+
Supported in all versions
Edge Edge
80+
11 or earlier ×
IE IE
11 or earlier ×
Opera Opera
48+
14 or earlier ×
iOS Safari iOS Safari
18+
Supported in all versions
Android Browser Android Browser
37+
4 or earlier ×
Chrome Android Chrome Android
36+
17 or earlier ×
Firefox Android Firefox Android
79+
3 or earlier ×

If you find any errors or copyright issues, please .