[html] How to style a checkbox using CSS

I prefer to use icon fonts (such as FontAwesome) since it's easy to modify their colours with CSS, and they scale really well on high pixel-density devices. So here's another pure CSS variant, using similar techniques to those above.

(Below is a static image so you can visualize the result; see the JSFiddle for an interactive version.)

Checkbox example

As with other solutions, it uses the label element. An adjacent span holds our checkbox character.

_x000D_
_x000D_
span.bigcheck-target {_x000D_
  font-family: FontAwesome; /* Use an icon font for the checkbox */_x000D_
}_x000D_
_x000D_
input[type='checkbox'].bigcheck {_x000D_
  position: relative;_x000D_
  left: -999em; /* Hide the real checkbox */_x000D_
}_x000D_
_x000D_
input[type='checkbox'].bigcheck + span.bigcheck-target:after {_x000D_
  content: "\f096"; /* In fontawesome, is an open square (fa-square-o) */_x000D_
}_x000D_
_x000D_
input[type='checkbox'].bigcheck:checked + span.bigcheck-target:after {_x000D_
  content: "\f046"; /* fontawesome checked box (fa-check-square-o) */_x000D_
}_x000D_
_x000D_
/* ==== Optional - colors and padding to make it look nice === */_x000D_
body {_x000D_
  background-color: #2C3E50;_x000D_
  color: #D35400;_x000D_
  font-family: sans-serif;_x000D_
  font-weight: 500;_x000D_
  font-size: 4em; /* Set this to whatever size you want */_x000D_
}_x000D_
_x000D_
span.bigcheck {_x000D_
  display: block;_x000D_
  padding: 0.5em;_x000D_
}
_x000D_
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" />_x000D_
_x000D_
<span class="bigcheck">_x000D_
  <label class="bigcheck">_x000D_
    Cheese_x000D_
    <input type="checkbox" class="bigcheck" name="cheese" value="yes" />_x000D_
    <span class="bigcheck-target"></span>_x000D_
  </label>_x000D_
</span>
_x000D_
_x000D_
_x000D_

Here's the JSFiddle for it.

Examples related to html

Embed ruby within URL : Middleman Blog Please help me convert this script to a simple image slider Generating a list of pages (not posts) without the index file Why there is this "clear" class before footer? Is it possible to change the content HTML5 alert messages? Getting all files in directory with ajax DevTools failed to load SourceMap: Could not load content for chrome-extension How to set width of mat-table column in angular? How to open a link in new tab using angular? ERROR Error: Uncaught (in promise), Cannot match any routes. URL Segment

Examples related to css

need to add a class to an element Using Lato fonts in my css (@font-face) Please help me convert this script to a simple image slider Why there is this "clear" class before footer? How to set width of mat-table column in angular? Center content vertically on Vuetify bootstrap 4 file input doesn't show the file name Bootstrap 4: responsive sidebar menu to top navbar Stylesheet not loaded because of MIME-type Force flex item to span full row width

Examples related to checkbox

Setting default checkbox value in Objective-C? Checkbox angular material checked by default Customize Bootstrap checkboxes Angular ReactiveForms: Producing an array of checkbox values? JQuery: if div is visible Angular 2 Checkbox Two Way Data Binding Launch an event when checking a checkbox in Angular2 Checkbox value true/false Angular 2: Get Values of Multiple Checked Checkboxes How to change the background color on a input checkbox with css?