The :checked pseudo-class styles form elements that are currently selected or toggled on. It is essential for customizing checkboxes, radio buttons, and toggle UIs.
01
Selected state
On or chosen.
02
Checkboxes
Toggled inputs.
03
Radio buttons
One of a group.
04
+ sibling
Style labels.
05
~ sibling
Show panels.
06
Custom UI
Toggle content.
Fundamentals
Introduction
The :checked selector in CSS is a pseudo-class used to style form elements that are checked or selected. It applies while an option remains in its on or chosen state.
This works with <input type="checkbox">, <input type="radio">, and <option> elements inside a <select> dropdown.
Definition and Usage
Append :checked to a selector with no space before the colon: input:checked or input[type="radio"]:checked. Styles apply whenever the element is selected and disappear when it is unchecked.
💡
Beginner Tip
Combine :checked with the + or ~ sibling combinator to style labels or reveal content when a hidden checkbox is toggled — a common pattern for custom forms without JavaScript.
Extra information appears when the checkbox is checked.
How It Works
The panel is hidden by default. When the checkbox is checked, .toggle-input:checked ~ .toggle-panel sets display: block on the sibling panel — no JavaScript required.
Watch Out
⚠️ Common Pitfalls
Wrong elements — :checked does not apply to text inputs, buttons, or plain divs.
HTML order — input:checked + label only works when the input comes directly before the label.
option styling — Browsers limit how option:checked can be styled inside <select>; test across browsers.
Hidden inputs — If you hide a checkbox for a custom UI, keep it focusable and pair with a visible label for accessibility.
A11y
♿ Accessibility
Real inputs — Keep a native checkbox or radio in the DOM, even if visually hidden, so keyboard and screen reader users can interact.
Labels — Always associate inputs with <label for="id"> or wrap the input inside the label.
Do not rely on color alone — Pair color changes with weight, icons, or text for selected states.
Focus styles — Style :focus alongside :checked for keyboard users.
🧠 How :checked Works
1
User selects an option
A click or keyboard action checks a box or chooses a radio button.
Input
2
Browser updates state
The element’s checked property becomes true and it matches :checked.
Match
3
Checked styles apply
Your CSS styles the input and any targeted siblings.
Render
=
✅
Clear selection feedback
Users see which options are active in the form.
Compatibility
Browser Compatibility
The :checked pseudo-class is supported in all modern browsers on checkboxes, radio buttons, and options.
✓ Universal · All browsers
Form state styling everywhere
:checked works reliably in Chrome, Firefox, Safari, Edge, and Opera.
99%Browser support
Google ChromeAll versions · Desktop & Mobile
Full support
Mozilla FirefoxAll versions · Desktop & Mobile
Full support
Apple SafariAll versions · macOS & iOS
Full support
Microsoft EdgeAll versions
Full support
OperaAll versions
Full support
:checked pseudo-class99% supported
Bottom line::checked is safe for checkbox, radio, and toggle patterns in modern projects.
Wrap Up
Conclusion
The :checked pseudo-class is a powerful way to style form elements based on their selection state. From simple outline highlights to CSS-only toggle panels, it makes forms more interactive and clear.
Combine it with sibling combinators for custom UIs, keep accessibility in mind with proper labels, and pair it with :focus and :disabled for complete form state coverage.
Use input[type="checkbox"]:checked for specificity
Style labels with input:checked + label
Keep native inputs in the DOM for accessibility
Combine with accent-color for quick theming
Test toggle panels with keyboard navigation
❌ Don’t
Apply :checked to non-checkable inputs
Remove inputs entirely for custom checkboxes
Rely only on color to show selection
Assume option:checked styles work everywhere
Confuse :checked with :active
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about :checked
Use these points when styling selected form controls.
5
Core concepts
☑01
Selected state
On or chosen.
Purpose
☐02
Checkbox
Toggle on/off.
Input
🔴03
Radio
One per group.
Input
➕04
+ label
Adjacent style.
Pattern
🌐05
99% support
All browsers.
Compat
❓ Frequently Asked Questions
The :checked pseudo-class matches form elements that are currently selected or toggled on, such as checked checkboxes, selected radio buttons, and selected option elements.
input[type="checkbox"], input[type="radio"], and option elements inside a select dropdown can be in a checked or selected state.
Yes. Use the adjacent sibling combinator: input:checked + label styles the label immediately after a checked input.
:checked reflects a persistent selected state. :active applies only while the user is pressing an element.
Yes. All modern browsers support the :checked pseudo-class on checkboxes, radio buttons, and options.