CSS3 :checked selector
Complete CSS Selector Reference Manual
Example
Set the height and width of all checked input elements:
input
:checked
{
height:
50
px
;
width:
50
px
;
}
Try it »
Definition and Usage
:checked selector matches every checked input element (only radio buttons or checkboxes).
:checked is a pseudo-class selector in CSS3 used to select checkboxes or radio buttons that are checked in form elements. When a user clicks a checkbox or radio button and selects it, the :checked selector takes effect. This allows you to change the style of an element or perform other actions when a user selects an option.
For example, you can use the :checked selector to change the style of a checked checkbox or radio button, or to link it with other elements. This is very useful for creating interactive forms or customizing the appearance of checkboxes and radio buttons.
Browser support
The numbers in the table indicate the first browser version that supports this property.
| Selector | |||||
|---|---|---|---|---|---|
| :checked | 4.0 | 9.0 | 3.5 | 3.2 | 9.6 |