HTML checked Attribute

Beginner
⏱️ 4 min read
📚 Updated: Jun 2026
🎯 2 Examples
Forms & Input

Introduction

The checked attribute is a fundamental feature in HTML, primarily associated with <input> elements of type checkbox or radio. It allows developers to preselect these controls so they appear selected when the page loads.

What You’ll Learn

01

Boolean

Presence = on.

02

Checkbox

Opt-in defaults.

03

Radio

One per group.

04

Labels

Always pair.

05

.checked

JS property.

06

defaultChecked

Initial state.

Purpose of checked

The primary purpose of the checked attribute is to set the initial state of a checkbox or radio button. When the attribute is present, the control is selected by default when the page loads. This is useful for newsletter opt-ins, remembered preferences, or a default choice in a radio group.

💡
Checkbox vs radio

Checkboxes can have multiple selections. Radio buttons with the same name form a group where only one can be selected at a time—mark only one radio as checked by default.

📝 Syntax

Add the boolean checked attribute to a checkbox or radio input:

checked.html
<input type="checkbox" id="subscribe" name="subscribe" checked>
<label for="subscribe">Subscribe to newsletter</label>

Syntax Rules

  • Boolean attribute—presence means selected; omit for unchecked.
  • Valid only on input type="checkbox" and input type="radio".
  • Do not write checked="false"—any value still checks the box in HTML.
  • Always associate inputs with a <label for="...">.
  • For radios, use the same name within a group and check only one by default.

💎 Values

The checked attribute is a boolean attribute, meaning it does not require a value. It can be present or absent:

  • Present — The checkbox or radio button is selected by default when the page loads.
  • Absent — The control is not selected initially.
checked-boolean.html
<!-- Checked by default -->
<input type="checkbox" checked>

<!-- Unchecked (omit checked) -->
<input type="checkbox">

<!-- Wrong: still checked in HTML -->
<input type="checkbox" checked="false">

⚡ Quick Reference

Use CaseMarkupNotes
Newsletter opt-in<input type="checkbox" checked>Pre-checked subscription
Default radio choice<input type="radio" name="plan" checked>One checked per name group
Toggle in JSinput.checked = trueCurrent selection state
Reset to initialinput.defaultCheckedOriginal HTML default
Uncheck in JSinput.checked = falseDo not use removeAttribute alone
Applicable typescheckbox, radioNot for text, email, etc.

Applicable Elements

Element / TypeSupported?Notes
<input type="checkbox">YesMost common use
<input type="radio">YesOne checked per name group
<input type="text">NoUse value instead
<select> / <option>NoUse selected on <option>
<button>NoNot a valid target

Examples Gallery

Checkbox example with checked and dynamic JavaScript .checked property.

👀 Live Preview

Pre-checked newsletter checkbox:

Example

Let’s explore a simple example of using the checked attribute with a checkbox:

checked.html
<input type="checkbox" id="subscribe" name="subscribe" checked>
<label for="subscribe">Subscribe to newsletter</label>
Try It Yourself

How It Works

In this example, the checkbox has the checked attribute present, indicating that it should be checked by default when the page loads.

Dynamic Values with JavaScript

You can also dynamically set or remove the checked state using JavaScript. Use the .checked property rather than setting the attribute to false:

checked.html
<input type="checkbox" id="dynamicCheckbox">

<script>
  // Set the checkbox to be checked dynamically
  document.getElementById("dynamicCheckbox").checked = true;
</script>
Try It Yourself

How It Works

In this script, the checked property is set to true for the checkbox with id dynamicCheckbox. This updates the current selection state and is the preferred way to toggle checkboxes at runtime.

♿ Accessibility

  • Always use labels — Connect every checkbox and radio to a <label> so assistive tech announces the purpose.
  • Pre-checked opt-ins — Be cautious pre-checking marketing checkboxes; some regulations require explicit consent.
  • Radio groups — Wrap related radios in a <fieldset> with a <legend>.
  • Visible focus — Ensure custom styles do not hide the focus ring on checked controls.
  • State is announced — Screen readers report checked/unchecked; do not rely on color alone.

🧠 How checked Works

1

Author adds checked

Include the boolean checked attribute on a checkbox or radio input.

Markup
2

Browser renders selected

The control appears checked when the page loads.

Display
3

User can toggle

Clicking changes the current state; radios in a group deselect siblings.

Interaction
=

Default form state set

On submit, checked controls include their name and value in form data.

Browser Support

The checked attribute is universally supported on checkbox and radio inputs in all modern browsers.

HTML standard · Essential

Supported everywhere

Checkbox and radio checked works consistently across all browsers.

100% Modern browsers
Google Chrome Full support
Supported
Mozilla Firefox Full support
Supported
Apple Safari Full support
Supported
Microsoft Edge Full support
Supported
checked attribute Universal

Bottom line: Use checked confidently on checkbox and radio inputs in all projects.

💡 Best Practices

✅ Do

  • Use checked for sensible default selections
  • Pair every input with a <label>
  • Check only one radio per name group by default
  • Toggle state with element.checked in JavaScript
  • Use fieldset and legend for radio groups

❌ Don’t

  • Write checked="false" expecting unchecked
  • Apply checked to text or email inputs
  • Pre-check multiple radios with the same name
  • Rely on color alone to show selected state
  • Pre-check consent boxes without legal review
  • Use the checked attribute to set the initial state of checkboxes or radio buttons when you want them selected by default.
  • If you need to change the state dynamically based on user interactions, use JavaScript to set the checked property.
  • Keep in mind that checked is specific to checkboxes and radio buttons. For other input types, use alternative attributes such as value or selected.

Conclusion

The checked attribute is a simple yet powerful tool for controlling the initial state of checkboxes and radio buttons in HTML. It sets user expectations and can streamline common form flows.

By understanding boolean syntax, radio group rules, and the JavaScript checked property, you can enhance the default behavior of your forms and improve user experience.

Key Takeaways

Knowledge Unlocked

Five truths every developer should know about checked

Bookmark these before building HTML forms.

5
Core concepts
☑️ 02

Checkbox

Multi select.

Type
🔴 03

Radio

One per name.

Group
⚙️ 04

.checked

JS toggle.

Script
📝 05

Labels

Always pair.

A11y

❓ Frequently Asked Questions

It preselects a checkbox or radio button so it appears checked when the page loads.
type="checkbox" and type="radio" only.
No. In HTML, any presence of checked means selected. Omit the attribute or set element.checked = false in JavaScript.
Assign element.checked = true or false. This is the preferred API for runtime changes.
defaultChecked reflects the original HTML default. checked reflects the current state, which may change after user interaction.
No. Use the selected attribute on <option> elements instead.

Preselect checkboxes and radio buttons

Practice the checked attribute on a newsletter checkbox and toggle selection dynamically with JavaScript.

Try checkbox example →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

5 people found this page helpful