splitforms.com

HTML · ATTRIBUTE

HTML checked Attribute: Default Checkbox and Radio

The checked boolean attribute sets the initial state of a checkbox or radio: its presence means on, even with checked="false". Only currently checked, enabled controls with a name submit name=value. A checkbox without a value attribute submits "on".

  • Live, editable example
  • Copy-paste snippet
  • Attributes & common mistakes
Live demo · nothing is sent

What gets submitted

Fill in the form above and press its button. The demo stops the request and lists every name=value pair the browser would send, plus the controls it leaves out.

With a free access key in the form, these fields land in your splitforms dashboard; access_key and botcheck are read by splitforms, not stored as lead data.

Edit the HTML and re-run it
Runs in a sandbox. Nothing is sent.

Minimal snippet

checked-example.html
<label><input type="checkbox" name="newsletter" value="yes" checked> Newsletter</label>
<fieldset>
  <legend>Contact method</legend>
  <label><input type="radio" name="contact" value="email" checked> Email</label>
  <label><input type="radio" name="contact" value="phone"> Phone</label>
</fieldset>

Want this form to email you its submissions? Point it at a free splitforms endpoint, with no server to build. Get a free access key →

Copy-paste code

HTML checked attribute code you can paste today.

Replace YOUR_ACCESS_KEY with a key from your free splitforms dashboard. The form posts to one endpoint — submissions land in your inbox and dashboard with spam filtering built in.

checked.html
<form action="https://splitforms.com/api/submit" method="POST">
  <input type="hidden" name="access_key" value="YOUR_ACCESS_KEY">
  <label for="email">Email</label>
  <input type="email" id="email" name="email" required>
  <label><input type="checkbox" name="newsletter" value="yes" checked> Subscribe to the newsletter</label>
  <fieldset>
    <legend>Preferred contact method</legend>
    <label><input type="radio" name="contact" value="email" checked> Email</label>
    <label><input type="radio" name="contact" value="phone"> Phone</label>
  </fieldset>
  <input type="checkbox" name="botcheck" style="display:none">
  <button type="submit">Send preferences</button>
</form>

Attributes · checked

Which attributes affect checked inputs?

The checked state, name and value determine the form data.

HTML checked attribute attributes and what each one does
AttributeWhat it doesDocs
checkedSets the default checked state on a checkbox or radio.MDN
valueThe value submitted when the control is checked; without it, the value is on.MDN
nameThe submitted key; radios with the same name form a group.MDN
disabledExcludes the control from submission, even when checked.MDN

Common mistakes

Checked attribute mistakes to avoid

Distinguish the default state from the current state and submitted data.

  1. checked="false" is still checked

    Boolean attributes are true when present. Remove checked to make the default unchecked.

  2. The attribute is not the current state

    el.defaultChecked reflects the attribute; el.checked reads or sets the current state. After user interaction changes the state, setAttribute changes the default without necessarily changing the visible state. Form reset restores the default.

  3. Unchecked controls are omitted

    An unchecked checkbox or radio sends no pair. A checked control also needs a name and must not be disabled to submit.

Sources: WHATWG HTML Standard: checked · MDN: checked property

Key benefits

Copy-paste ready

The HTML checked attribute example below is a complete, working form — paste it into any HTML page and it submits, no edits to the markup required.

No backend to build

Your html checked attribute form posts to one endpoint. No server, PHP, or API route — accepted submissions are saved to your dashboard before owner notification email is attempted; delivery time and inbox placement depend on provider and recipient settings.

A form that really submits

Unlike a static reference snippet, this checked form actually sends data to a free splitforms backend, with spam filtering built in.

How it works

How to add HTML checked attribute to any page.

Copy the html checked attribute example, drop in your free access key, and paste it into any page — submissions start landing in your dashboard.

  1. Copy the code

    Copy the HTML checked attribute example below.

  2. Add your access key

    Replace YOUR_ACCESS_KEY with a free splitforms key from the dashboard.

  3. Paste into your site

    Drop the form into any HTML page. Submissions arrive in your dashboard.

Questions

HTML checked attribute questions, answered.

Anything missing? Email us, we read every message.

A person reading answers to common questions
How do I check a checkbox or radio by default?

Add the `checked` attribute to the checkbox or to one radio in a same-named group. Remove the attribute for an unchecked default; `checked="false"` still counts as present.

What is the difference between checked, :checked and .checked?

The HTML `checked` attribute sets the default. CSS `:checked` matches the current checked state. The JavaScript property `el.checked` reads or changes that current state, while `el.defaultChecked` reflects the attribute.

Why does setAttribute not update a checkbox after interaction?

Once interaction changes checkedness, the control's checkedness is dirty. Changing the attribute updates the default but does not overwrite the current state; set `el.checked` to change it directly.

How can I send a value when a checkbox is unchecked?

Place `<input type="hidden" name="newsletter" value="no">` before a checkbox with the same name and value="yes". When checked, both pairs are submitted, so configure the server to handle duplicate names and select the intended value.

What gets submitted for checked inputs?

Each enabled, named checked checkbox sends its name and value, or "on" if value is missing. A radio group sends the selected enabled radio's pair; an unchecked control sends nothing.

View all FAQs

Make this form actually submit.

Point your form at splitforms. 500 free submissions a month, spam filtering, webhooks on paid plans — no server.

  • No credit card required
  • 500 free submissions
  • Setup in minutes
Two people celebrating a working contact form