In this code, the .disabled class is applied to disabled checkboxes. The
opacity property is set to 0.5, which makes the checkbox translucent. The
cursor property is set to not-allowed, which prevents the checkbox from being clicked.
The .checked class is applied to checked checkboxes. The background-color property is set to #2196F3, which is the color of the checked checkbox. The
border-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:
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.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
To change the style of disabled and checked checkboxes, you can use the
disabledandcheckedCSS properties.The
disabledproperty disables the checkbox and prevents it from being checked. Thecheckedproperty checks the checkbox.The following CSS code changes the style of disabled and checked checkboxes:
CSS
In this code, the
.disabledclass is applied to disabled checkboxes. Theopacityproperty is set to 0.5, which makes the checkbox translucent. Thecursorproperty is set tonot-allowed, which prevents the checkbox from being clicked.The
.checkedclass is applied to checked checkboxes. Thebackground-colorproperty is set to #2196F3, which is the color of the checked checkbox. Theborder-colorproperty is also set to #2196F3.You can also use the
:disabledand:checkedpseudo-classes to style disabled and checked checkboxes. The following CSS code is equivalent to the previous code:CSS
In this code, the
.checkboxclass is applied to all checkboxes. The:disabledpseudo-class is applied to disabled checkboxes and the:checkedpseudo-class is applied to checked checkboxes.