Content · Web Development · HTML

HTML input type="checkbox": Independent On-Off Choices

input type="checkbox": Independent On-Off Choices: Checking the box submits updates=yes; leaving it unchecked normally sends no updates entry. Includes a practical HTML example and an explanation.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

A form should feel easy to use. The visitor sees a question, gives an answer, and needs to know what will happen next.

What You Need to Know


This example uses the browser’s built-in checkbox control, so you do not have to create a picker from scratch.

In this example: choose newsletter topics.

Try the Example


Take a look at the example. We’ll explain the important lines right below it.

<form action="/preferences" method="post">
    <label>
        <input type="checkbox" name="updates" value="yes" checked>
        Send me project updates
    </label>
    <button type="submit">Save preferences</button>
</form>

Let’s Read the Code


  • <form>: The form groups controls and identifies where submitted data goes.
  • <label>: The label tells people what the input is for. A matching for/id pair makes the label clickable.
  • type: Type changes what sort of control or resource the browser uses.
  • name: The name is the key used for the submitted value.

What the example shows: Checking the box submits updates=yes; leaving it unchecked normally sends no updates entry.

What Happens in the Browser?


The HTML controls work in the browser, but saving an answer requires the example action path to be handled by a real server.

What gets sent? With ordinary form submission, the browser builds a set of name/value entries. For checkboxes, only checked choices are normally included. Radio buttons in the same group contribute one selected value. Open the browser Network panel to see the request rather than guessing.

Your Turn


Remove checked, submit again, and compare which values are sent.

Common Beginner Mistakes


  • Copying the example without giving the fields a clear label and a usable name.
  • Do not assume an unchecked box sends false automatically.

Key Takeaways


  • A control needs a clear label and, when submitted, a meaningful name and value.
  • <form>: The form groups controls and identifies where submitted data goes.
  • Remember that HTML form rules help the visitor, but server-side code must decide whether received data is valid.
Share this resourceSend this page to someone who may find it useful.