How to change the style of disabled and checked checkboxes?
How to change the style of disabled and checked checkboxes?
27417-Aug-2023
Updated on 18-Aug-2023
Home / DeveloperSection / Forums / How to change the style of disabled and checked checkboxes?
How to change the style of disabled and checked checkboxes?
Aryan Kumar
18-Aug-2023To change the style of disabled and checked checkboxes, you can use the
disabled
andchecked
CSS properties.The
disabled
property disables the checkbox and prevents it from being checked. Thechecked
property checks the checkbox.The following CSS code changes the style of disabled and checked checkboxes:
CSS
In this code, the
.disabled
class is applied to disabled checkboxes. Theopacity
property is set to 0.5, which makes the checkbox translucent. Thecursor
property is set tonot-allowed
, which prevents the checkbox from being clicked.The
.checked
class is applied to checked checkboxes. Thebackground-color
property is set to #2196F3, which is the color of the checked checkbox. Theborder-color
property is also set to #2196F3.You can also use the
:disabled
and:checked
pseudo-classes to style disabled and checked checkboxes. The following CSS code is equivalent to the previous code:CSS
In this code, the
.checkbox
class is applied to all checkboxes. The:disabled
pseudo-class is applied to disabled checkboxes and the:checked
pseudo-class is applied to checked checkboxes.