Languages
[Edit]
EN

CSS - style input checkbox (HTML element)

3 points
Created by:
Kevin
797

In this article, we would like to show you how to style input checkbox using pure CSS.

Input checkbox styled using CSS.
Input checkbox styled using CSS.

Practical example

Edit

In this example, we use :checked pseudo class to switch between .default and .checked style changing SVG icon when the checkbox input is clicked.

In the below source code, you can configure own colors by changing:

  • #5f6368 - label font color
  • #767676 - icon border color          (unchecked state)
  • #ffffff - icon background color  (unchecked state)
                       check icon color            (checked state)
  • #0075ff - icon background color  (checked state)

Source code:

 

Multiple checkboxes

Edit

In this example, we create two checkbox inputs.

 

Multiple checkboxes (with SVG components)

Edit

In this example, we use SVG components to avoid icons source code duplications.

 

See also

Edit
  1. HTML - checkbox input

  2. HTML - select checkbox on click on related text

  3. CSS - style radio button (HTML element)

  4. SVG - create reusable component in pure HTML

References

Edit
  1. <input type="checkbox"> - HTML: HyperText Markup Language | MDN

Alternative titles

  1. CSS - style input check box on click event (HTML element)
  2. CSS - style input check box onclick (HTML element)
  3. Pure CSS - style input checkbox (HTML element)
1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join