CSS3 :checked pseudo-class
- Previous page :autofill
- Next Page :default
- Go to the Previous Level CSS Pseudo-class Reference Manual
Definition and usage
CSS :checked
pseudo-classes are used to match any selected <input> or <option> .
This applies to <input type="radio">, <input type="checkbox">, and <option> elements within <select>.
Example
Example 1
Set a thin red outline for all selected <input> elements:
input:checked { outline: 1px solid red; }
Example 2
Set different styles for radio buttons, checkboxes, and options when selected:
input[type="radio"]:checked { box-shadow: 0 0 5px 3px blue; } input[type="checkbox"]:checked { box-shadow: 0 0 5px 3px maroon; } option:checked { color: blue; background-color: pink; }
CSS syntax
:checked { css declarations; }
Technical details
Version: | CSS3 |
---|
Browser support
The numbers in the table specify the first browser version to fully support the pseudo-class.
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
4.0 | 9.0 | 3.5 | 3.2 | 9.6 |
- Previous page :autofill
- Next Page :default
- Go to the Previous Level CSS Pseudo-class Reference Manual