[html] Can I change the checkbox size using CSS?

Is it possible to set the size of a checkbox using CSS or HTML across browsers?

width and size work in IE6+, but not with Firefox, where the checkbox stays 16x16 even if I set a smaller size.

This question is related to html css

The answer is


Preview:
http://jsfiddle.net/h4qka9td/

_x000D_
_x000D_
*,*:after,*:before {_x000D_
  -webkit-box-sizing: border-box;_x000D_
  -moz-box-sizing: border-box;_x000D_
  box-sizing: border-box;_x000D_
  padding: 0;_x000D_
  margin: 0;_x000D_
}_x000D_
_x000D_
.switch {_x000D_
  margin: 50px auto;_x000D_
  position: relative;_x000D_
}_x000D_
_x000D_
.switch label {_x000D_
  width: 100%;_x000D_
  height: 100%;_x000D_
  position: relative;_x000D_
  display: block;_x000D_
}_x000D_
_x000D_
.switch input {_x000D_
  top: 0; _x000D_
  right: 0; _x000D_
  bottom: 0; _x000D_
  left: 0;_x000D_
  opacity: 0;_x000D_
  z-index: 100;_x000D_
  position: absolute;_x000D_
  width: 100%;_x000D_
  height: 100%;_x000D_
  cursor: pointer;_x000D_
}_x000D_
_x000D_
/* DEMO 3 */_x000D_
_x000D_
.switch.demo3 {_x000D_
  width: 180px;_x000D_
  height: 50px;_x000D_
}_x000D_
_x000D_
.switch.demo3 label {_x000D_
  display: block;_x000D_
  width: 100%;_x000D_
  height: 100%;_x000D_
  background: #a5a39d;_x000D_
  border-radius: 40px;_x000D_
  box-shadow:_x000D_
      inset 0 3px 8px 1px rgba(0,0,0,0.2),_x000D_
      0 1px 0 rgba(255,255,255,0.5);_x000D_
}_x000D_
_x000D_
.switch.demo3 label:after {_x000D_
  content: "";_x000D_
  position: absolute;_x000D_
  z-index: -1;_x000D_
  top: -8px; right: -8px; bottom: -8px; left: -8px;_x000D_
  border-radius: inherit;_x000D_
  background: #ababab;_x000D_
  background: -moz-linear-gradient(#f2f2f2, #ababab);_x000D_
  background: -ms-linear-gradient(#f2f2f2, #ababab);_x000D_
  background: -o-linear-gradient(#f2f2f2, #ababab);_x000D_
  background: -webkit-gradient(linear, 0 0, 0 100%, from(#f2f2f2), to(#ababab));_x000D_
  background: -webkit-linear-gradient(#f2f2f2, #ababab);_x000D_
  background: linear-gradient(#f2f2f2, #ababab);_x000D_
  box-shadow: 0 0 10px rgba(0,0,0,0.3),_x000D_
        0 1px 1px rgba(0,0,0,0.25);_x000D_
}_x000D_
_x000D_
.switch.demo3 label:before {_x000D_
  content: "";_x000D_
  position: absolute;_x000D_
  z-index: -1;_x000D_
  top: -18px; right: -18px; bottom: -18px; left: -18px;_x000D_
  border-radius: inherit;_x000D_
  background: #eee;_x000D_
  background: -moz-linear-gradient(#e5e7e6, #eee);_x000D_
  background: -ms-linear-gradient(#e5e7e6, #eee);_x000D_
  background: -o-linear-gradient(#e5e7e6, #eee);_x000D_
  background: -webkit-gradient(linear, 0 0, 0 100%, from(#e5e7e6), to(#eee));_x000D_
  background: -webkit-linear-gradient(#e5e7e6, #eee);_x000D_
  background: linear-gradient(#e5e7e6, #eee);_x000D_
  box-shadow:_x000D_
      0 1px 0 rgba(255,255,255,0.5);_x000D_
  -webkit-filter: blur(1px);_x000D_
  -moz-filter: blur(1px);_x000D_
  -ms-filter: blur(1px);_x000D_
  -o-filter: blur(1px);_x000D_
  filter: blur(1px);_x000D_
}_x000D_
_x000D_
.switch.demo3 label i {_x000D_
  display: block;_x000D_
  height: 100%;_x000D_
  width: 60%;_x000D_
  border-radius: inherit;_x000D_
  background: silver;_x000D_
  position: absolute;_x000D_
  z-index: 2;_x000D_
  right: 40%;_x000D_
  top: 0;_x000D_
  background: #b2ac9e;_x000D_
  background: -moz-linear-gradient(#f7f2f6, #b2ac9e);_x000D_
  background: -ms-linear-gradient(#f7f2f6, #b2ac9e);_x000D_
  background: -o-linear-gradient(#f7f2f6, #b2ac9e);_x000D_
  background: -webkit-gradient(linear, 0 0, 0 100%, from(#f7f2f6), to(#b2ac9e));_x000D_
  background: -webkit-linear-gradient(#f7f2f6, #b2ac9e);_x000D_
  background: linear-gradient(#f7f2f6, #b2ac9e);_x000D_
  box-shadow:_x000D_
      inset 0 1px 0 white,_x000D_
      0 0 8px rgba(0,0,0,0.3),_x000D_
      0 5px 5px rgba(0,0,0,0.2);_x000D_
}_x000D_
_x000D_
.switch.demo3 label i:after {_x000D_
  content: "";_x000D_
  position: absolute;_x000D_
  left: 15%;_x000D_
  top: 25%;_x000D_
  width: 70%;_x000D_
  height: 50%;_x000D_
  background: #d2cbc3;_x000D_
  background: -moz-linear-gradient(#cbc7bc, #d2cbc3);_x000D_
  background: -ms-linear-gradient(#cbc7bc, #d2cbc3);_x000D_
  background: -o-linear-gradient(#cbc7bc, #d2cbc3);_x000D_
  background: -webkit-gradient(linear, 0 0, 0 100%, from(#cbc7bc), to(#d2cbc3));_x000D_
  background: -webkit-linear-gradient(#cbc7bc, #d2cbc3);_x000D_
  background: linear-gradient(#cbc7bc, #d2cbc3);_x000D_
  border-radius: inherit;_x000D_
}_x000D_
_x000D_
.switch.demo3 label i:before {_x000D_
  content: "off";_x000D_
  text-transform: uppercase;_x000D_
  font-style: normal;_x000D_
  font-weight: bold;_x000D_
  color: rgba(0,0,0,0.4);_x000D_
  text-shadow: 0 1px 0 #bcb8ae, 0 -1px 0 #97958e;_x000D_
  font-family: Helvetica, Arial, sans-serif;_x000D_
  font-size: 24px;_x000D_
  position: absolute;_x000D_
  top: 50%;_x000D_
  margin-top: -12px;_x000D_
  right: -50%;_x000D_
}_x000D_
_x000D_
.switch.demo3 input:checked ~ label {_x000D_
  background: #9abb82;_x000D_
}_x000D_
_x000D_
.switch.demo3 input:checked ~ label i {_x000D_
  right: -1%;_x000D_
}_x000D_
_x000D_
.switch.demo3 input:checked ~ label i:before {_x000D_
  content: "on";_x000D_
  right: 115%;_x000D_
  color: #82a06a;_x000D_
  text-shadow: _x000D_
    0 1px 0 #afcb9b,_x000D_
    0 -1px 0 #6b8659;_x000D_
}
_x000D_
<div class="switch demo3">_x000D_
  <input type="checkbox">_x000D_
  <label><i></i>_x000D_
  </label>_x000D_
</div>_x000D_
_x000D_
<div class="switch demo3">_x000D_
  <input type="checkbox" checked>_x000D_
  <label><i></i>_x000D_
  </label>_x000D_
</div>
_x000D_
_x000D_
_x000D_


You can make checkboxes larger in Safari — which is generally resistant to the usual approaches — with this attribute: -webkit-transform: scale(1.3, 1.3);

Source


The problem is Firefox doesn't listen to width and height. Disable that and your good to go.

_x000D_
_x000D_
input[type=checkbox] {_x000D_
    width: 25px;_x000D_
    height: 25px;_x000D_
    -moz-appearance: none;_x000D_
}
_x000D_
<label><input type="checkbox"> Test</label>
_x000D_
_x000D_
_x000D_


The appearance of checkboxes seems to be fixed by default. But as pointed out by Worthy7 this can be remedied using CSS appearance property. It will make checkboxes completely empty, so you can define your own appearance. What is nice about this: You can use your existing HTML code. Downside: It is experimental technology. Edge (legacy) and IE do not use the custom style.

Here are the needed CSS styles:

_x000D_
_x000D_
input[type=checkbox] {
    width: 14mm;
    -webkit-appearance: none;
    -moz-appearance: none;
    height: 14mm;
    border: 0.1mm solid black;
}

input[type=checkbox]:checked {
    background-color: lightblue;
}

input[type=checkbox]:checked:after {
    margin-left: 4.3mm;
    margin-top: -0.4mm;
    width: 3mm;
    height: 10mm;
    border: solid white;
    border-width: 0 2mm 2mm 0;
    -webkit-transform: rotate(45deg);
    -moz-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg);
    content: "";
    display: inline-block;
}
_x000D_
<label><input type="checkbox"> Test</label>
_x000D_
_x000D_
_x000D_

Screenshots:

Chrome: enter image description here

Firefox: enter image description here

Edge: enter image description here

Edge (legacy): enter image description here

IE: enter image description here


Preview:
http://jsfiddle.net/h4qka9td/

_x000D_
_x000D_
*,*:after,*:before {_x000D_
  -webkit-box-sizing: border-box;_x000D_
  -moz-box-sizing: border-box;_x000D_
  box-sizing: border-box;_x000D_
  padding: 0;_x000D_
  margin: 0;_x000D_
}_x000D_
_x000D_
.switch {_x000D_
  margin: 50px auto;_x000D_
  position: relative;_x000D_
}_x000D_
_x000D_
.switch label {_x000D_
  width: 100%;_x000D_
  height: 100%;_x000D_
  position: relative;_x000D_
  display: block;_x000D_
}_x000D_
_x000D_
.switch input {_x000D_
  top: 0; _x000D_
  right: 0; _x000D_
  bottom: 0; _x000D_
  left: 0;_x000D_
  opacity: 0;_x000D_
  z-index: 100;_x000D_
  position: absolute;_x000D_
  width: 100%;_x000D_
  height: 100%;_x000D_
  cursor: pointer;_x000D_
}_x000D_
_x000D_
/* DEMO 3 */_x000D_
_x000D_
.switch.demo3 {_x000D_
  width: 180px;_x000D_
  height: 50px;_x000D_
}_x000D_
_x000D_
.switch.demo3 label {_x000D_
  display: block;_x000D_
  width: 100%;_x000D_
  height: 100%;_x000D_
  background: #a5a39d;_x000D_
  border-radius: 40px;_x000D_
  box-shadow:_x000D_
      inset 0 3px 8px 1px rgba(0,0,0,0.2),_x000D_
      0 1px 0 rgba(255,255,255,0.5);_x000D_
}_x000D_
_x000D_
.switch.demo3 label:after {_x000D_
  content: "";_x000D_
  position: absolute;_x000D_
  z-index: -1;_x000D_
  top: -8px; right: -8px; bottom: -8px; left: -8px;_x000D_
  border-radius: inherit;_x000D_
  background: #ababab;_x000D_
  background: -moz-linear-gradient(#f2f2f2, #ababab);_x000D_
  background: -ms-linear-gradient(#f2f2f2, #ababab);_x000D_
  background: -o-linear-gradient(#f2f2f2, #ababab);_x000D_
  background: -webkit-gradient(linear, 0 0, 0 100%, from(#f2f2f2), to(#ababab));_x000D_
  background: -webkit-linear-gradient(#f2f2f2, #ababab);_x000D_
  background: linear-gradient(#f2f2f2, #ababab);_x000D_
  box-shadow: 0 0 10px rgba(0,0,0,0.3),_x000D_
        0 1px 1px rgba(0,0,0,0.25);_x000D_
}_x000D_
_x000D_
.switch.demo3 label:before {_x000D_
  content: "";_x000D_
  position: absolute;_x000D_
  z-index: -1;_x000D_
  top: -18px; right: -18px; bottom: -18px; left: -18px;_x000D_
  border-radius: inherit;_x000D_
  background: #eee;_x000D_
  background: -moz-linear-gradient(#e5e7e6, #eee);_x000D_
  background: -ms-linear-gradient(#e5e7e6, #eee);_x000D_
  background: -o-linear-gradient(#e5e7e6, #eee);_x000D_
  background: -webkit-gradient(linear, 0 0, 0 100%, from(#e5e7e6), to(#eee));_x000D_
  background: -webkit-linear-gradient(#e5e7e6, #eee);_x000D_
  background: linear-gradient(#e5e7e6, #eee);_x000D_
  box-shadow:_x000D_
      0 1px 0 rgba(255,255,255,0.5);_x000D_
  -webkit-filter: blur(1px);_x000D_
  -moz-filter: blur(1px);_x000D_
  -ms-filter: blur(1px);_x000D_
  -o-filter: blur(1px);_x000D_
  filter: blur(1px);_x000D_
}_x000D_
_x000D_
.switch.demo3 label i {_x000D_
  display: block;_x000D_
  height: 100%;_x000D_
  width: 60%;_x000D_
  border-radius: inherit;_x000D_
  background: silver;_x000D_
  position: absolute;_x000D_
  z-index: 2;_x000D_
  right: 40%;_x000D_
  top: 0;_x000D_
  background: #b2ac9e;_x000D_
  background: -moz-linear-gradient(#f7f2f6, #b2ac9e);_x000D_
  background: -ms-linear-gradient(#f7f2f6, #b2ac9e);_x000D_
  background: -o-linear-gradient(#f7f2f6, #b2ac9e);_x000D_
  background: -webkit-gradient(linear, 0 0, 0 100%, from(#f7f2f6), to(#b2ac9e));_x000D_
  background: -webkit-linear-gradient(#f7f2f6, #b2ac9e);_x000D_
  background: linear-gradient(#f7f2f6, #b2ac9e);_x000D_
  box-shadow:_x000D_
      inset 0 1px 0 white,_x000D_
      0 0 8px rgba(0,0,0,0.3),_x000D_
      0 5px 5px rgba(0,0,0,0.2);_x000D_
}_x000D_
_x000D_
.switch.demo3 label i:after {_x000D_
  content: "";_x000D_
  position: absolute;_x000D_
  left: 15%;_x000D_
  top: 25%;_x000D_
  width: 70%;_x000D_
  height: 50%;_x000D_
  background: #d2cbc3;_x000D_
  background: -moz-linear-gradient(#cbc7bc, #d2cbc3);_x000D_
  background: -ms-linear-gradient(#cbc7bc, #d2cbc3);_x000D_
  background: -o-linear-gradient(#cbc7bc, #d2cbc3);_x000D_
  background: -webkit-gradient(linear, 0 0, 0 100%, from(#cbc7bc), to(#d2cbc3));_x000D_
  background: -webkit-linear-gradient(#cbc7bc, #d2cbc3);_x000D_
  background: linear-gradient(#cbc7bc, #d2cbc3);_x000D_
  border-radius: inherit;_x000D_
}_x000D_
_x000D_
.switch.demo3 label i:before {_x000D_
  content: "off";_x000D_
  text-transform: uppercase;_x000D_
  font-style: normal;_x000D_
  font-weight: bold;_x000D_
  color: rgba(0,0,0,0.4);_x000D_
  text-shadow: 0 1px 0 #bcb8ae, 0 -1px 0 #97958e;_x000D_
  font-family: Helvetica, Arial, sans-serif;_x000D_
  font-size: 24px;_x000D_
  position: absolute;_x000D_
  top: 50%;_x000D_
  margin-top: -12px;_x000D_
  right: -50%;_x000D_
}_x000D_
_x000D_
.switch.demo3 input:checked ~ label {_x000D_
  background: #9abb82;_x000D_
}_x000D_
_x000D_
.switch.demo3 input:checked ~ label i {_x000D_
  right: -1%;_x000D_
}_x000D_
_x000D_
.switch.demo3 input:checked ~ label i:before {_x000D_
  content: "on";_x000D_
  right: 115%;_x000D_
  color: #82a06a;_x000D_
  text-shadow: _x000D_
    0 1px 0 #afcb9b,_x000D_
    0 -1px 0 #6b8659;_x000D_
}
_x000D_
<div class="switch demo3">_x000D_
  <input type="checkbox">_x000D_
  <label><i></i>_x000D_
  </label>_x000D_
</div>_x000D_
_x000D_
<div class="switch demo3">_x000D_
  <input type="checkbox" checked>_x000D_
  <label><i></i>_x000D_
  </label>_x000D_
</div>
_x000D_
_x000D_
_x000D_


The other answers showed a pixelated checkbox, while I wanted something beautiful. The result looks like this: checkbox preview

Even though this version is more complicated I think it's worth giving it a try.

_x000D_
_x000D_
.checkbox-list__item {_x000D_
  position: relative;_x000D_
  padding: 10px 0;_x000D_
  display: block;_x000D_
  cursor: pointer;_x000D_
  margin: 0 0 0 34px;_x000D_
  border-bottom: 1px solid #b4bcc2;_x000D_
}_x000D_
.checkbox-list__item:last-of-type {_x000D_
  border-bottom: 0;_x000D_
}_x000D_
_x000D_
.checkbox-list__check {_x000D_
  width: 18px;_x000D_
  height: 18px;_x000D_
  border: 3px solid #b4bcc2;_x000D_
  position: absolute;_x000D_
  left: -34px;_x000D_
  top: 50%;_x000D_
  margin-top: -12px;_x000D_
  transition: border .3s ease;_x000D_
  border-radius: 5px;_x000D_
}_x000D_
.checkbox-list__check:before {_x000D_
  position: absolute;_x000D_
  display: block;_x000D_
  width: 18px;_x000D_
  height: 22px;_x000D_
  top: -2px;_x000D_
  left: 0px;_x000D_
  padding-left: 2px;_x000D_
  background-color: transparent;_x000D_
  transition: background-color .3s ease;_x000D_
  content: '\2713';_x000D_
  font-family: initial;_x000D_
  font-size: 19px;_x000D_
  color: white;_x000D_
}_x000D_
_x000D_
input[type="checkbox"]:checked ~ .checkbox-list__check {_x000D_
  border-color: #5bc0de;_x000D_
}_x000D_
input[type="checkbox"]:checked ~ .checkbox-list__check:before {_x000D_
  background-color: #5bc0de;_x000D_
}
_x000D_
<label class="checkbox-list__item">_x000D_
  <input class="checkbox_buttons" type="checkbox" checked="checked" style="display: none;">_x000D_
  <div class="checkbox-list__check"></div>_x000D_
</label>
_x000D_
_x000D_
_x000D_

JSFiddle: https://jsfiddle.net/asbd4hpr/


The problem is Firefox doesn't listen to width and height. Disable that and your good to go.

_x000D_
_x000D_
input[type=checkbox] {_x000D_
    width: 25px;_x000D_
    height: 25px;_x000D_
    -moz-appearance: none;_x000D_
}
_x000D_
<label><input type="checkbox"> Test</label>
_x000D_
_x000D_
_x000D_


My reputation is slightly too low to post comments, but I made a modification to Jack Miller's code above in order to get it to not change size when you check and uncheck it. This was causing text alignment problems for me.

_x000D_
_x000D_
    input[type=checkbox] {
        width: 17px;
        -webkit-appearance: none;
        -moz-appearance: none;
        height: 17px;
        border: 1px solid black;
    }

    input[type=checkbox]:checked {
        background-color: #F58027;
    }

    input[type=checkbox]:checked:after {
        margin-left: 4px;
        margin-top: -1px;
        width: 4px;
        height: 12px;
        border: solid white;
        border-width: 0 2px 2px 0;
        -webkit-transform: rotate(45deg);
        -moz-transform: rotate(45deg);
        -ms-transform: rotate(45deg);
        transform: rotate(45deg);
        content: "";
        display: inline-block;
    }
    input[type=checkbox]:after {
        margin-left: 4px;
        margin-top: -1px;
        width: 4px;
        height: 12px;
        border: solid white;
        border-width: 0;
        -webkit-transform: rotate(45deg);
        -moz-transform: rotate(45deg);
        -ms-transform: rotate(45deg);
        transform: rotate(45deg);
        content: "";
        display: inline-block;
    }
_x000D_
<label><input type="checkbox"> Test</label>
_x000D_
_x000D_
_x000D_


I think the simplest solution is re-style the checkbox as some users suggest. The CSS below is working for me, only requires a few lines of CSS, and answers the OP question:

input[type=checkbox] {
    -webkit-appearance: none;
    -moz-appearance: none;
    vertical-align: middle;
    width: 14px; 
    height: 14px;
    font-size: 14px;
    background-color: #eee;
}

input[type=checkbox]:checked:after {
    position: relative;
    bottom: 3px;
    left: 1px;
    color: blue;
    content: "\2713"; /* check mark */
}

As mentioned in this post, the zoom property seems not to work on Firefox, and transforms may cause undesired effects.

Tested on Chrome and Firefox, should work for all modern browsers. Just change the properties (colors, size, bottom, left, etc.) to your needs. Hope it helps!


My understanding is that this isn't easy at all to do cross-browser. Instead of trying to manipulate the checkbox control, you could always build your own implementation using images, javascript, and hidden input fields. I'm assuming this is similar to what niceforms is (from Staicu lonut's answer above), but wouldn't be particularly difficult to implement. I believe jQuery has a plugin to allow for this custom behavior as well (will look for the link and post here if I can find it).


you can chnage the height and width in the code below

_x000D_
_x000D_
.checkmark {_x000D_
    position: absolute;_x000D_
    top: 0;_x000D_
    left: 0;_x000D_
    height: 20px;_x000D_
    width: 20px;_x000D_
    border-radius:5px;_x000D_
    border:1px solid #ff7e02;_x000D_
}
_x000D_
<div class="check">_x000D_
_x000D_
     <label class="container1">Architecture/Landscape_x000D_
            _x000D_
_x000D_
    <input type="checkbox" checked="checked">_x000D_
            _x000D_
_x000D_
    <span class="checkmark"></span>_x000D_
         _x000D_
_x000D_
 </label>_x000D_
</div>
_x000D_
_x000D_
_x000D_


An easy solution is use the property zoom:

_x000D_
_x000D_
input[type="checkbox"] {_x000D_
    zoom: 1.5;_x000D_
}
_x000D_
<input type="checkbox" />
_x000D_
_x000D_
_x000D_


I was looking to make a checkbox that was just a little bit larger and looked at the source code for 37Signals Basecamp to find the following solution-

You can change the font size to make the checkbox slightly larger:

font-size: x-large;

Then, you can align the checkbox properly by doing:

vertical-align: top;
margin-top: 3px; /* change to center it */

2020 version - using pseudo-elements, size depends on font size.

Default checkbox/radio is rendered outside of screen, but CSS creates virtual elements very similar to default elements. Supports all browsers, no blur. Size depends on font size. Keyboard actions (space, tabs) are also supported.

https://jsfiddle.net/ohf7nmzy/2/

_x000D_
_x000D_
body{_x000D_
 padding:0 20px;_x000D_
}_x000D_
.big{_x000D_
 font-size: 50px;_x000D_
}_x000D_
_x000D_
/* CSS below will force radio/checkbox size be same as font size */_x000D_
label{_x000D_
 position: relative;_x000D_
 line-height: 1.4;_x000D_
}_x000D_
/* radio */_x000D_
input[type=radio]{_x000D_
 width: 1em;_x000D_
 font-size: inherit;_x000D_
 margin: 0;_x000D_
 transform: translateX(-9999px);_x000D_
}_x000D_
input[type=radio] + label:before{_x000D_
 position: absolute;_x000D_
 content: '';_x000D_
 left: -1.3em;_x000D_
 top: 0;_x000D_
 width: 1em;_x000D_
 height: 1em;_x000D_
 margin: 0;_x000D_
 border:none;_x000D_
 border-radius: 50%;_x000D_
 background-color: #bbbbbb;_x000D_
}_x000D_
input[type=radio] + label:after{_x000D_
 position: absolute;_x000D_
 content: '';_x000D_
 left: -1.3em;_x000D_
 top: 0;_x000D_
 width: 1em;_x000D_
 height: 1em;_x000D_
 margin: 0;_x000D_
 border: none;_x000D_
 background-color: white;_x000D_
 border-radius: 50%;_x000D_
 transform: scale(0.8);_x000D_
}_x000D_
/*checked*/_x000D_
input[type=radio]:checked + label:before{_x000D_
 position:absolute;_x000D_
 content:'';_x000D_
 left: -1.3em;_x000D_
 top: 0;_x000D_
 width: 1em;_x000D_
 height: 1em;_x000D_
 margin: 0;_x000D_
 border: none;_x000D_
 background-color: #3b88fd;_x000D_
}_x000D_
input[type=radio]:checked + label:after{_x000D_
 position: absolute;_x000D_
 content: '';_x000D_
 left: -1.3em;_x000D_
 top: 0;_x000D_
 width: 1em;_x000D_
 height: 1em;_x000D_
 margin: 0;_x000D_
 border: none;_x000D_
 background-color: white;_x000D_
 border-radius: 50%;_x000D_
 transform: scale(0.3);_x000D_
}_x000D_
/*focused*/_x000D_
input[type=radio]:focus + label:before{_x000D_
 border: 0.2em solid #8eb9fb;_x000D_
 margin-top: -0.2em;_x000D_
 margin-left: -0.2em;_x000D_
 box-shadow: 0 0 0.3em #3b88fd;_x000D_
}_x000D_
_x000D_
_x000D_
/*checkbox/*/_x000D_
input[type=checkbox]{_x000D_
 width: 1em;_x000D_
 font-size: inherit;_x000D_
 margin: 0;_x000D_
 transform: translateX(-9999px);_x000D_
}_x000D_
input[type=checkbox] + label:before{_x000D_
 position: absolute;_x000D_
 content: '';_x000D_
 left: -1.3em;_x000D_
 top: 0;_x000D_
 width: 1em;_x000D_
 height: 1em;_x000D_
 margin: 0;_x000D_
 border:none;_x000D_
 border-radius: 10%;_x000D_
 background-color: #bbbbbb;_x000D_
}_x000D_
input[type=checkbox] + label:after{_x000D_
 position: absolute;_x000D_
 content: '';_x000D_
 left: -1.3em;_x000D_
 top: 0;_x000D_
 width: 1em;_x000D_
 height: 1em;_x000D_
 margin: 0;_x000D_
 border: none;_x000D_
 background-color: white;_x000D_
 border-radius: 10%;_x000D_
 transform: scale(0.8);_x000D_
}_x000D_
/*checked*/_x000D_
input[type=checkbox]:checked + label:before{_x000D_
 position:absolute;_x000D_
 content:'';_x000D_
 left: -1.3em;_x000D_
 top: 0;_x000D_
 width: 1em;_x000D_
 height: 1em;_x000D_
 margin: 0;_x000D_
 border: none;_x000D_
 background-color: #3b88fd;_x000D_
}_x000D_
input[type=checkbox]:checked + label:after{_x000D_
 position: absolute;_x000D_
 content: "\2713";_x000D_
 left: -1.3em;_x000D_
 top: 0;_x000D_
 width: 1em;_x000D_
 height: 1em;_x000D_
 margin: 0;_x000D_
 border: none;_x000D_
 background-color: #3b88fd;_x000D_
 border-radius: 10%;_x000D_
 color: white;_x000D_
 text-align: center;_x000D_
 line-height: 1;_x000D_
}_x000D_
/*focused*/_x000D_
input[type=checkbox]:focus + label:before{_x000D_
 border: 0.1em solid #8eb9fb;_x000D_
 margin-top: -0.1em;_x000D_
 margin-left: -0.1em;_x000D_
 box-shadow: 0 0 0.2em #3b88fd;_x000D_
}
_x000D_
<input type="checkbox" name="checkbox_1" id="ee" checked /> _x000D_
<label for="ee">Checkbox small</label>_x000D_
_x000D_
<br />_x000D_
_x000D_
<input type="checkbox" name="checkbox_2" id="ff" /> _x000D_
<label for="ff">Checkbox small</label>_x000D_
_x000D_
<hr />_x000D_
_x000D_
<div class="big">_x000D_
 <input type="checkbox" name="checkbox_3" id="gg" checked /> _x000D_
 <label for="gg">Checkbox big</label>_x000D_
_x000D_
 <br />_x000D_
_x000D_
 <input type="checkbox" name="checkbox_4" id="hh" /> _x000D_
 <label for="hh">Checkbox big</label>_x000D_
</div>_x000D_
_x000D_
_x000D_
<hr />_x000D_
_x000D_
_x000D_
<input type="radio" name="radio_1" id="aa" value="1" checked /> _x000D_
<label for="aa">Radio small</label>_x000D_
_x000D_
<br />_x000D_
_x000D_
<input type="radio" name="radio_1" id="bb" value="2" /> _x000D_
<label for="bb">Radio small</label>_x000D_
_x000D_
<hr />_x000D_
_x000D_
<div class="big">_x000D_
 <input type="radio" name="radio_2" id="cc" value="1" checked /> _x000D_
 <label for="cc">Radio big</label>_x000D_
_x000D_
 <br />_x000D_
_x000D_
 <input type="radio" name="radio_2" id="dd" value="2" /> _x000D_
 <label for="dd">Radio big</label>_x000D_
</div>
_x000D_
_x000D_
_x000D_

2017 version - using zoom or scale

Browser will use non-standard zoom feature if it is supported (nice quality) or standard transform: scale (blurry).

Scaling works on all browsers, but it will be blurry on Firefox and Safari.

https://jsfiddle.net/ksvx2txb/11/

_x000D_
_x000D_
@supports (zoom:2) {_x000D_
 input[type="radio"],  input[type=checkbox]{_x000D_
 zoom: 2;_x000D_
 }_x000D_
}_x000D_
@supports not (zoom:2) {_x000D_
 input[type="radio"],  input[type=checkbox]{_x000D_
  transform: scale(2);_x000D_
  margin: 15px;_x000D_
 }_x000D_
}_x000D_
label{_x000D_
  /* fix vertical align issues */_x000D_
 display: inline-block;_x000D_
 vertical-align: top;_x000D_
 margin-top: 10px;_x000D_
}
_x000D_
<input type="radio" name="aa" value="1" id="aa" checked /> _x000D_
<label for="aa">Radio 1</label>_x000D_
<br />_x000D_
<input type="radio" name="aa" value="2" id="bb" /> _x000D_
<label for="bb">Radio 2</label>_x000D_
_x000D_
<br /><br />_x000D_
_x000D_
<input  type="checkbox" name="optiona" id="cc" checked /> _x000D_
<label for="cc">Checkbox 1</label>_x000D_
<br />_x000D_
<input  type="checkbox" name="optiona" id="dd" /> _x000D_
<label for="dd">Checkbox 1</label>
_x000D_
_x000D_
_x000D_


The appearance of checkboxes seems to be fixed by default. But as pointed out by Worthy7 this can be remedied using CSS appearance property. It will make checkboxes completely empty, so you can define your own appearance. What is nice about this: You can use your existing HTML code. Downside: It is experimental technology. Edge (legacy) and IE do not use the custom style.

Here are the needed CSS styles:

_x000D_
_x000D_
input[type=checkbox] {
    width: 14mm;
    -webkit-appearance: none;
    -moz-appearance: none;
    height: 14mm;
    border: 0.1mm solid black;
}

input[type=checkbox]:checked {
    background-color: lightblue;
}

input[type=checkbox]:checked:after {
    margin-left: 4.3mm;
    margin-top: -0.4mm;
    width: 3mm;
    height: 10mm;
    border: solid white;
    border-width: 0 2mm 2mm 0;
    -webkit-transform: rotate(45deg);
    -moz-transform: rotate(45deg);
    -ms-transform: rotate(45deg);
    transform: rotate(45deg);
    content: "";
    display: inline-block;
}
_x000D_
<label><input type="checkbox"> Test</label>
_x000D_
_x000D_
_x000D_

Screenshots:

Chrome: enter image description here

Firefox: enter image description here

Edge: enter image description here

Edge (legacy): enter image description here

IE: enter image description here


The other answers showed a pixelated checkbox, while I wanted something beautiful. The result looks like this: checkbox preview

Even though this version is more complicated I think it's worth giving it a try.

_x000D_
_x000D_
.checkbox-list__item {_x000D_
  position: relative;_x000D_
  padding: 10px 0;_x000D_
  display: block;_x000D_
  cursor: pointer;_x000D_
  margin: 0 0 0 34px;_x000D_
  border-bottom: 1px solid #b4bcc2;_x000D_
}_x000D_
.checkbox-list__item:last-of-type {_x000D_
  border-bottom: 0;_x000D_
}_x000D_
_x000D_
.checkbox-list__check {_x000D_
  width: 18px;_x000D_
  height: 18px;_x000D_
  border: 3px solid #b4bcc2;_x000D_
  position: absolute;_x000D_
  left: -34px;_x000D_
  top: 50%;_x000D_
  margin-top: -12px;_x000D_
  transition: border .3s ease;_x000D_
  border-radius: 5px;_x000D_
}_x000D_
.checkbox-list__check:before {_x000D_
  position: absolute;_x000D_
  display: block;_x000D_
  width: 18px;_x000D_
  height: 22px;_x000D_
  top: -2px;_x000D_
  left: 0px;_x000D_
  padding-left: 2px;_x000D_
  background-color: transparent;_x000D_
  transition: background-color .3s ease;_x000D_
  content: '\2713';_x000D_
  font-family: initial;_x000D_
  font-size: 19px;_x000D_
  color: white;_x000D_
}_x000D_
_x000D_
input[type="checkbox"]:checked ~ .checkbox-list__check {_x000D_
  border-color: #5bc0de;_x000D_
}_x000D_
input[type="checkbox"]:checked ~ .checkbox-list__check:before {_x000D_
  background-color: #5bc0de;_x000D_
}
_x000D_
<label class="checkbox-list__item">_x000D_
  <input class="checkbox_buttons" type="checkbox" checked="checked" style="display: none;">_x000D_
  <div class="checkbox-list__check"></div>_x000D_
</label>
_x000D_
_x000D_
_x000D_

JSFiddle: https://jsfiddle.net/asbd4hpr/


You can make checkboxes larger in Safari — which is generally resistant to the usual approaches — with this attribute: -webkit-transform: scale(1.3, 1.3);

Source


I just came out with this:

_x000D_
_x000D_
input[type="checkbox"] {display:none;}_x000D_
input[type="checkbox"] + label:before {content:"?";}_x000D_
input:checked + label:before {content:"?";}_x000D_
label:hover {color:blue;}
_x000D_
<input id="check" type="checkbox" /><label for="check">Checkbox</label>
_x000D_
_x000D_
_x000D_

Of course, thanks to this, you can change the value of content to your needs and use an image if you wish or use another font...

The main interest here is that:

  1. The checkbox size stays proportional to the text size

  2. You can control the aspect, the color, the size of the checkbox

  3. No extra HTML needed !

  4. Only 3 lines of CSS needed (the last one is just to give you ideas)

Edit: As pointed out in the comment, the checkbox won't be accessible by key navigation. You should probably add tabindex=0 as a property for your label to make it focusable.


It's a little ugly (due to the scaling up), but it works on most newer browsers:

_x000D_
_x000D_
input[type=checkbox]_x000D_
{_x000D_
  /* Double-sized Checkboxes */_x000D_
  -ms-transform: scale(2); /* IE */_x000D_
  -moz-transform: scale(2); /* FF */_x000D_
  -webkit-transform: scale(2); /* Safari and Chrome */_x000D_
  -o-transform: scale(2); /* Opera */_x000D_
  transform: scale(2);_x000D_
  padding: 10px;_x000D_
}_x000D_
_x000D_
/* Might want to wrap a span around your checkbox text */_x000D_
.checkboxtext_x000D_
{_x000D_
  /* Checkbox text */_x000D_
  font-size: 110%;_x000D_
  display: inline;_x000D_
}
_x000D_
<input  type="checkbox" name="optiona" id="opta" checked />_x000D_
<span class="checkboxtext">_x000D_
  Option A_x000D_
</span>_x000D_
<input type="checkbox" name="optionb" id="optb" />_x000D_
<span class="checkboxtext">_x000D_
  Option B_x000D_
</span>_x000D_
<input type="checkbox" name="optionc" id="optc" />_x000D_
<span class="checkboxtext">_x000D_
  Option C_x000D_
</span>
_x000D_
_x000D_
_x000D_


I found this CSS-only library to be very helpful: https://lokesh-coder.github.io/pretty-checkbox/

Or, you could roll your own with this same basic concept, similar to what @Sharcoux posted. It's basically:

  • Hide the normal checkbox (opacity 0 and placed where it would go)
  • Add a css-based fake checkbox
  • Use input:checked~div label for the checked style
  • make sure your <label> is clickable using for=yourinputID

_x000D_
_x000D_
.pretty {_x000D_
  position: relative;_x000D_
  margin: 1em;_x000D_
}_x000D_
.pretty input {_x000D_
  position: absolute;_x000D_
  left: 0;_x000D_
  top: 0;_x000D_
  min-width: 1em;_x000D_
  width: 100%;_x000D_
  height: 100%;_x000D_
  z-index: 2;_x000D_
  opacity: 0;_x000D_
  margin: 0;_x000D_
  padding: 0;_x000D_
  cursor: pointer;_x000D_
}_x000D_
.pretty-inner {_x000D_
  box-sizing: border-box;_x000D_
  position: relative;_x000D_
}_x000D_
.pretty-inner label {_x000D_
  position: initial;_x000D_
  display: inline-block;_x000D_
  font-weight: 400;_x000D_
  margin: 0;_x000D_
  text-indent: 1.5em;_x000D_
  min-width: calc(1em + 2px);_x000D_
}_x000D_
.pretty-inner label:after,_x000D_
.pretty-inner label:before {_x000D_
  content: '';_x000D_
  width: calc(1em + 2px);_x000D_
  height: calc(1em + 2px);_x000D_
  display: block;_x000D_
  box-sizing: border-box;_x000D_
  border-radius: 0;_x000D_
  border: 1px solid transparent;_x000D_
  z-index: 0;_x000D_
  position: absolute;_x000D_
  left: 0;_x000D_
  top: 0;_x000D_
  background-color: transparent;_x000D_
}_x000D_
.pretty-inner label:before {_x000D_
  border-color: #bdc3c7;_x000D_
}_x000D_
.pretty input:checked~.pretty-inner label:after {_x000D_
  background-color: #00bb82;_x000D_
  width: calc(1em - 6px);_x000D_
  height: calc(1em - 6px);_x000D_
  top: 4px;_x000D_
  left: 4px;_x000D_
}_x000D_
_x000D_
_x000D_
/* Add checkmark character style */_x000D_
.pretty input:checked~.pretty-inner.checkmark:after {_x000D_
  content: '\2713';_x000D_
  color: #fff;_x000D_
  position: absolute;_x000D_
  font-size: 0.65em;_x000D_
  left: 6px;_x000D_
  top: 3px;_x000D_
}_x000D_
_x000D_
_x000D_
_x000D_
body {_x000D_
  font-size: 20px;_x000D_
  font-family: sans-serif;_x000D_
}
_x000D_
<div class="pretty">_x000D_
 <input type="checkbox" id="demo" name="demo">_x000D_
 <div class="pretty-inner"><label for="demo">I agree.</label></div>_x000D_
</div>_x000D_
_x000D_
<div class="pretty">_x000D_
 <input type="checkbox" id="demo" name="demo">_x000D_
 <div class="pretty-inner checkmark"><label for="demo">Please check the box.</label></div>_x000D_
</div>
_x000D_
_x000D_
_x000D_


2020 version - using pseudo-elements, size depends on font size.

Default checkbox/radio is rendered outside of screen, but CSS creates virtual elements very similar to default elements. Supports all browsers, no blur. Size depends on font size. Keyboard actions (space, tabs) are also supported.

https://jsfiddle.net/ohf7nmzy/2/

_x000D_
_x000D_
body{_x000D_
 padding:0 20px;_x000D_
}_x000D_
.big{_x000D_
 font-size: 50px;_x000D_
}_x000D_
_x000D_
/* CSS below will force radio/checkbox size be same as font size */_x000D_
label{_x000D_
 position: relative;_x000D_
 line-height: 1.4;_x000D_
}_x000D_
/* radio */_x000D_
input[type=radio]{_x000D_
 width: 1em;_x000D_
 font-size: inherit;_x000D_
 margin: 0;_x000D_
 transform: translateX(-9999px);_x000D_
}_x000D_
input[type=radio] + label:before{_x000D_
 position: absolute;_x000D_
 content: '';_x000D_
 left: -1.3em;_x000D_
 top: 0;_x000D_
 width: 1em;_x000D_
 height: 1em;_x000D_
 margin: 0;_x000D_
 border:none;_x000D_
 border-radius: 50%;_x000D_
 background-color: #bbbbbb;_x000D_
}_x000D_
input[type=radio] + label:after{_x000D_
 position: absolute;_x000D_
 content: '';_x000D_
 left: -1.3em;_x000D_
 top: 0;_x000D_
 width: 1em;_x000D_
 height: 1em;_x000D_
 margin: 0;_x000D_
 border: none;_x000D_
 background-color: white;_x000D_
 border-radius: 50%;_x000D_
 transform: scale(0.8);_x000D_
}_x000D_
/*checked*/_x000D_
input[type=radio]:checked + label:before{_x000D_
 position:absolute;_x000D_
 content:'';_x000D_
 left: -1.3em;_x000D_
 top: 0;_x000D_
 width: 1em;_x000D_
 height: 1em;_x000D_
 margin: 0;_x000D_
 border: none;_x000D_
 background-color: #3b88fd;_x000D_
}_x000D_
input[type=radio]:checked + label:after{_x000D_
 position: absolute;_x000D_
 content: '';_x000D_
 left: -1.3em;_x000D_
 top: 0;_x000D_
 width: 1em;_x000D_
 height: 1em;_x000D_
 margin: 0;_x000D_
 border: none;_x000D_
 background-color: white;_x000D_
 border-radius: 50%;_x000D_
 transform: scale(0.3);_x000D_
}_x000D_
/*focused*/_x000D_
input[type=radio]:focus + label:before{_x000D_
 border: 0.2em solid #8eb9fb;_x000D_
 margin-top: -0.2em;_x000D_
 margin-left: -0.2em;_x000D_
 box-shadow: 0 0 0.3em #3b88fd;_x000D_
}_x000D_
_x000D_
_x000D_
/*checkbox/*/_x000D_
input[type=checkbox]{_x000D_
 width: 1em;_x000D_
 font-size: inherit;_x000D_
 margin: 0;_x000D_
 transform: translateX(-9999px);_x000D_
}_x000D_
input[type=checkbox] + label:before{_x000D_
 position: absolute;_x000D_
 content: '';_x000D_
 left: -1.3em;_x000D_
 top: 0;_x000D_
 width: 1em;_x000D_
 height: 1em;_x000D_
 margin: 0;_x000D_
 border:none;_x000D_
 border-radius: 10%;_x000D_
 background-color: #bbbbbb;_x000D_
}_x000D_
input[type=checkbox] + label:after{_x000D_
 position: absolute;_x000D_
 content: '';_x000D_
 left: -1.3em;_x000D_
 top: 0;_x000D_
 width: 1em;_x000D_
 height: 1em;_x000D_
 margin: 0;_x000D_
 border: none;_x000D_
 background-color: white;_x000D_
 border-radius: 10%;_x000D_
 transform: scale(0.8);_x000D_
}_x000D_
/*checked*/_x000D_
input[type=checkbox]:checked + label:before{_x000D_
 position:absolute;_x000D_
 content:'';_x000D_
 left: -1.3em;_x000D_
 top: 0;_x000D_
 width: 1em;_x000D_
 height: 1em;_x000D_
 margin: 0;_x000D_
 border: none;_x000D_
 background-color: #3b88fd;_x000D_
}_x000D_
input[type=checkbox]:checked + label:after{_x000D_
 position: absolute;_x000D_
 content: "\2713";_x000D_
 left: -1.3em;_x000D_
 top: 0;_x000D_
 width: 1em;_x000D_
 height: 1em;_x000D_
 margin: 0;_x000D_
 border: none;_x000D_
 background-color: #3b88fd;_x000D_
 border-radius: 10%;_x000D_
 color: white;_x000D_
 text-align: center;_x000D_
 line-height: 1;_x000D_
}_x000D_
/*focused*/_x000D_
input[type=checkbox]:focus + label:before{_x000D_
 border: 0.1em solid #8eb9fb;_x000D_
 margin-top: -0.1em;_x000D_
 margin-left: -0.1em;_x000D_
 box-shadow: 0 0 0.2em #3b88fd;_x000D_
}
_x000D_
<input type="checkbox" name="checkbox_1" id="ee" checked /> _x000D_
<label for="ee">Checkbox small</label>_x000D_
_x000D_
<br />_x000D_
_x000D_
<input type="checkbox" name="checkbox_2" id="ff" /> _x000D_
<label for="ff">Checkbox small</label>_x000D_
_x000D_
<hr />_x000D_
_x000D_
<div class="big">_x000D_
 <input type="checkbox" name="checkbox_3" id="gg" checked /> _x000D_
 <label for="gg">Checkbox big</label>_x000D_
_x000D_
 <br />_x000D_
_x000D_
 <input type="checkbox" name="checkbox_4" id="hh" /> _x000D_
 <label for="hh">Checkbox big</label>_x000D_
</div>_x000D_
_x000D_
_x000D_
<hr />_x000D_
_x000D_
_x000D_
<input type="radio" name="radio_1" id="aa" value="1" checked /> _x000D_
<label for="aa">Radio small</label>_x000D_
_x000D_
<br />_x000D_
_x000D_
<input type="radio" name="radio_1" id="bb" value="2" /> _x000D_
<label for="bb">Radio small</label>_x000D_
_x000D_
<hr />_x000D_
_x000D_
<div class="big">_x000D_
 <input type="radio" name="radio_2" id="cc" value="1" checked /> _x000D_
 <label for="cc">Radio big</label>_x000D_
_x000D_
 <br />_x000D_
_x000D_
 <input type="radio" name="radio_2" id="dd" value="2" /> _x000D_
 <label for="dd">Radio big</label>_x000D_
</div>
_x000D_
_x000D_
_x000D_

2017 version - using zoom or scale

Browser will use non-standard zoom feature if it is supported (nice quality) or standard transform: scale (blurry).

Scaling works on all browsers, but it will be blurry on Firefox and Safari.

https://jsfiddle.net/ksvx2txb/11/

_x000D_
_x000D_
@supports (zoom:2) {_x000D_
 input[type="radio"],  input[type=checkbox]{_x000D_
 zoom: 2;_x000D_
 }_x000D_
}_x000D_
@supports not (zoom:2) {_x000D_
 input[type="radio"],  input[type=checkbox]{_x000D_
  transform: scale(2);_x000D_
  margin: 15px;_x000D_
 }_x000D_
}_x000D_
label{_x000D_
  /* fix vertical align issues */_x000D_
 display: inline-block;_x000D_
 vertical-align: top;_x000D_
 margin-top: 10px;_x000D_
}
_x000D_
<input type="radio" name="aa" value="1" id="aa" checked /> _x000D_
<label for="aa">Radio 1</label>_x000D_
<br />_x000D_
<input type="radio" name="aa" value="2" id="bb" /> _x000D_
<label for="bb">Radio 2</label>_x000D_
_x000D_
<br /><br />_x000D_
_x000D_
<input  type="checkbox" name="optiona" id="cc" checked /> _x000D_
<label for="cc">Checkbox 1</label>_x000D_
<br />_x000D_
<input  type="checkbox" name="optiona" id="dd" /> _x000D_
<label for="dd">Checkbox 1</label>
_x000D_
_x000D_
_x000D_


Working solution for all modern browsers.

_x000D_
_x000D_
input[type=checkbox] {_x000D_
    transform: scale(1.5);_x000D_
}
_x000D_
<label><input type="checkbox"> Test</label>
_x000D_
_x000D_
_x000D_


Compatibility:

  • IE: 10+
  • FF: 16+
  • Chrome: 36+
  • Safari: 9+
  • Opera: 23+
  • iOS Safari: 9.2+
  • Chrome for Android: 51+

Appearance:

  • Scaled checkboxes on Chrome, Win 10 Chrome 58 (May 2017), Windows 10

My understanding is that this isn't easy at all to do cross-browser. Instead of trying to manipulate the checkbox control, you could always build your own implementation using images, javascript, and hidden input fields. I'm assuming this is similar to what niceforms is (from Staicu lonut's answer above), but wouldn't be particularly difficult to implement. I believe jQuery has a plugin to allow for this custom behavior as well (will look for the link and post here if I can find it).


I was looking to make a checkbox that was just a little bit larger and looked at the source code for 37Signals Basecamp to find the following solution-

You can change the font size to make the checkbox slightly larger:

font-size: x-large;

Then, you can align the checkbox properly by doing:

vertical-align: top;
margin-top: 3px; /* change to center it */

My reputation is slightly too low to post comments, but I made a modification to Jack Miller's code above in order to get it to not change size when you check and uncheck it. This was causing text alignment problems for me.

_x000D_
_x000D_
    input[type=checkbox] {
        width: 17px;
        -webkit-appearance: none;
        -moz-appearance: none;
        height: 17px;
        border: 1px solid black;
    }

    input[type=checkbox]:checked {
        background-color: #F58027;
    }

    input[type=checkbox]:checked:after {
        margin-left: 4px;
        margin-top: -1px;
        width: 4px;
        height: 12px;
        border: solid white;
        border-width: 0 2px 2px 0;
        -webkit-transform: rotate(45deg);
        -moz-transform: rotate(45deg);
        -ms-transform: rotate(45deg);
        transform: rotate(45deg);
        content: "";
        display: inline-block;
    }
    input[type=checkbox]:after {
        margin-left: 4px;
        margin-top: -1px;
        width: 4px;
        height: 12px;
        border: solid white;
        border-width: 0;
        -webkit-transform: rotate(45deg);
        -moz-transform: rotate(45deg);
        -ms-transform: rotate(45deg);
        transform: rotate(45deg);
        content: "";
        display: inline-block;
    }
_x000D_
<label><input type="checkbox"> Test</label>
_x000D_
_x000D_
_x000D_


I just came out with this:

_x000D_
_x000D_
input[type="checkbox"] {display:none;}_x000D_
input[type="checkbox"] + label:before {content:"?";}_x000D_
input:checked + label:before {content:"?";}_x000D_
label:hover {color:blue;}
_x000D_
<input id="check" type="checkbox" /><label for="check">Checkbox</label>
_x000D_
_x000D_
_x000D_

Of course, thanks to this, you can change the value of content to your needs and use an image if you wish or use another font...

The main interest here is that:

  1. The checkbox size stays proportional to the text size

  2. You can control the aspect, the color, the size of the checkbox

  3. No extra HTML needed !

  4. Only 3 lines of CSS needed (the last one is just to give you ideas)

Edit: As pointed out in the comment, the checkbox won't be accessible by key navigation. You should probably add tabindex=0 as a property for your label to make it focusable.


you can chnage the height and width in the code below

_x000D_
_x000D_
.checkmark {_x000D_
    position: absolute;_x000D_
    top: 0;_x000D_
    left: 0;_x000D_
    height: 20px;_x000D_
    width: 20px;_x000D_
    border-radius:5px;_x000D_
    border:1px solid #ff7e02;_x000D_
}
_x000D_
<div class="check">_x000D_
_x000D_
     <label class="container1">Architecture/Landscape_x000D_
            _x000D_
_x000D_
    <input type="checkbox" checked="checked">_x000D_
            _x000D_
_x000D_
    <span class="checkmark"></span>_x000D_
         _x000D_
_x000D_
 </label>_x000D_
</div>
_x000D_
_x000D_
_x000D_


It's a little ugly (due to the scaling up), but it works on most newer browsers:

_x000D_
_x000D_
input[type=checkbox]_x000D_
{_x000D_
  /* Double-sized Checkboxes */_x000D_
  -ms-transform: scale(2); /* IE */_x000D_
  -moz-transform: scale(2); /* FF */_x000D_
  -webkit-transform: scale(2); /* Safari and Chrome */_x000D_
  -o-transform: scale(2); /* Opera */_x000D_
  transform: scale(2);_x000D_
  padding: 10px;_x000D_
}_x000D_
_x000D_
/* Might want to wrap a span around your checkbox text */_x000D_
.checkboxtext_x000D_
{_x000D_
  /* Checkbox text */_x000D_
  font-size: 110%;_x000D_
  display: inline;_x000D_
}
_x000D_
<input  type="checkbox" name="optiona" id="opta" checked />_x000D_
<span class="checkboxtext">_x000D_
  Option A_x000D_
</span>_x000D_
<input type="checkbox" name="optionb" id="optb" />_x000D_
<span class="checkboxtext">_x000D_
  Option B_x000D_
</span>_x000D_
<input type="checkbox" name="optionc" id="optc" />_x000D_
<span class="checkboxtext">_x000D_
  Option C_x000D_
</span>
_x000D_
_x000D_
_x000D_


My understanding is that this isn't easy at all to do cross-browser. Instead of trying to manipulate the checkbox control, you could always build your own implementation using images, javascript, and hidden input fields. I'm assuming this is similar to what niceforms is (from Staicu lonut's answer above), but wouldn't be particularly difficult to implement. I believe jQuery has a plugin to allow for this custom behavior as well (will look for the link and post here if I can find it).


I think the simplest solution is re-style the checkbox as some users suggest. The CSS below is working for me, only requires a few lines of CSS, and answers the OP question:

input[type=checkbox] {
    -webkit-appearance: none;
    -moz-appearance: none;
    vertical-align: middle;
    width: 14px; 
    height: 14px;
    font-size: 14px;
    background-color: #eee;
}

input[type=checkbox]:checked:after {
    position: relative;
    bottom: 3px;
    left: 1px;
    color: blue;
    content: "\2713"; /* check mark */
}

As mentioned in this post, the zoom property seems not to work on Firefox, and transforms may cause undesired effects.

Tested on Chrome and Firefox, should work for all modern browsers. Just change the properties (colors, size, bottom, left, etc.) to your needs. Hope it helps!


Working solution for all modern browsers.

_x000D_
_x000D_
input[type=checkbox] {_x000D_
    transform: scale(1.5);_x000D_
}
_x000D_
<label><input type="checkbox"> Test</label>
_x000D_
_x000D_
_x000D_


Compatibility:

  • IE: 10+
  • FF: 16+
  • Chrome: 36+
  • Safari: 9+
  • Opera: 23+
  • iOS Safari: 9.2+
  • Chrome for Android: 51+

Appearance:

  • Scaled checkboxes on Chrome, Win 10 Chrome 58 (May 2017), Windows 10

My understanding is that this isn't easy at all to do cross-browser. Instead of trying to manipulate the checkbox control, you could always build your own implementation using images, javascript, and hidden input fields. I'm assuming this is similar to what niceforms is (from Staicu lonut's answer above), but wouldn't be particularly difficult to implement. I believe jQuery has a plugin to allow for this custom behavior as well (will look for the link and post here if I can find it).