Home CSS Selectors :checked CSS :checked Pseudo-class Definition
Definition and Usage The :checked pseudo-class matches a form control that is on or selected : a checked checkbox, a selected radio button, or a selected option.
Users turn the state on by checking or selecting; they turn it off by unchecking or choosing another option. It is great for custom form look and simple CSS-only toggles.
Baseline · Widely available. Not deprecated. Cross-browser since about July 2015.
Styling note. Native checkboxes and option elements are limited to style in some browsers. Sibling selectors (+, ~) often style the label or nearby UI instead.
Syntax
CSS Syntax :checked { /* styles when checked / selected */ }
Often combined with a type: input[type="checkbox"]:checked or with a sibling: input:checked + label.
Patterns
Common Patterns Pattern Description Try it Checkbox Style input[type="checkbox"]:checked Try itRadio Style the selected radio in a group Try itLabel sibling input:checked + label styles the label Try itToggle panel Show content with :checked ~ siblings Try itoption:checkedSelected option in a select (support varies) Try itAccent color Combine with accent-color for a quick tint Try it
Approach
How to Use :checked Wire labels correctly, then style the checked state (or its neighbors).
Use a real checkbox or radio with a linked <label>. Add :checked styles for the control and/or + label. For toggles, keep the input as a sibling of the content you show/hide. Test with keyboard (Space / arrows) as well as the mouse. Try it
Live Preview Check the boxes and radios. Labels turn bold blue when the control is :checked.
Code
CSS Examples Each snippet focuses on :checked. Use Try It Yourself for a live editor.
1. Checkbox 2. Label sibling 3. Toggle panel Example 1 — Checkbox Outline Highlight a checkbox when it is checked.
<style>
input[type="checkbox"]:checked {
outline: 2px solid #db2777;
outline-offset: 2px;
}
</style>
<label>
<input type="checkbox"> I agree
</label> How It Works Target checkboxes. input[type="checkbox"] limits the rule.Add :checked. Styles apply only while the box is on.Use an outline. A pink ring makes the state easy to see.Click or press Space. The outline appears and disappears with the state.Example 2 — Style the Label When the input is checked, style the label that follows it.
<style>
input:checked + label {
color: #2563eb;
font-weight: 700;
}
</style>
<input type="checkbox" id="news">
<label for="news">Subscribe</label> How It Works Order matters. The label must be the next sibling of the input.+ combinator. Selects only that adjacent label.:checked gates the style. Unchecked labels stay normal.Keep for/id. Clicking the label still toggles the box.Example 3 — Toggle Panel Show extra content when a checkbox is checked — no JavaScript.
<style>
.panel { display: none; }
#more:checked ~ .panel { display: block; }
</style>
<input type="checkbox" id="more">
<label for="more">Show details</label>
<p class="panel">Extra details appear when checked.</p> How It Works Hide by default. .panel { display: none; }.Keep siblings. Checkbox, label, and panel share one parent.:checked ~ .panel. When checked, later siblings that match .panel show.Label toggles the input. Accessible with keyboard and click. Edge Cases & Pitfalls Most bugs come from DOM order, missing labels, or over-hiding the real control.
siblings + needs the next siblinginput:checked + label fails if the label wraps the input or sits before it. Match the HTML order to the combinator.
options option:checked styling is limitedBrowsers treat many option UIs as OS widgets. Do not rely on fancy option:checked styles everywhere.
a11y Do not remove keyboard access If you visually hide the input for a custom control, keep it focusable and tied to a proper label (avoid display: none without a careful pattern).
vs-active Not the same as :active :active is only while pressing. :checked stays until the user changes the selection.
indeterminate Tri-state checkboxes A mixed checkbox uses :indeterminate , not :checked.
Compatibility
Browser Support :checked is a browser CSS pseudo-class for form state. Node.js, Deno, and Bun do not apply it.
✓ Baseline · Widely available
:checked Supported in all modern browsers and IE 9+. Widely available since July 2015.
Google Chrome 1+
Full support
Mozilla Firefox 1+
Full support
Apple Safari 3.1+
Full support
Microsoft Edge 12+
Full support
Opera 9+
Full support
Samsung Internet 1+
Full support
Internet Explorer 9+
Full support :checked Widely supported
Bottom line: Safe for form UI everywhere. Prefer styling labels/siblings when native controls are hard to theme. It is not a runtime API.
Remember
Key Takeaways Role: match checked checkboxes, selected radios, and selected options.
Siblings: + / ~ let you style labels and panels from the state.
Persistent: stays on until the user changes the control.
Labels first: accessible for/id pairs beat pure decoration.
One line: use :checked to style selected form controls and CSS-only toggles.
Frequently Asked Questions What does the CSS :checked pseudo-class do? It matches form controls that are on or selected: checked checkboxes, selected radio buttons, and selected option elements.
Which elements support :checked? input type checkbox, input type radio, and option inside a select.
How do I style a label when a checkbox is checked? Place the label after the input and use input:checked + label, or use :has() in modern browsers.
What is the difference between :checked and :active? :checked is a lasting selected state. :active only applies while the pointer is pressed.
Can I toggle a panel with :checked only? Yes. A checkbox plus sibling combinators (such as ~) can show or hide content without JavaScript.
Which browsers support :checked? It is Baseline and widely available since about July 2015. It is a browser CSS pseudo-class, not a Node.js API.
Next: :default Select the default submit button or selected option in a form.
:default tutorial → About the author Developer, cloud engineer, and technical writer
I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.
8 people found this page helpful
Helpful Share Copy link Suggestion