Advanced Search Usage Terms Submit Contact
Dynamic Drive CSS Library

CSS Library: Form CSS: CSS3 demos: Here

CSS3 checkbox and radio button replacements

Author: Dynamic Drive

By hiding the default INPUT element of a checkbox/ radio button and styling its associated LABEL element instead, checkboxes and radio buttons can take on an entirely new look while maintaining their functionality inside a form. The following demonstrates just that. The custom checkbox and radio buttons you see are actually label elements richly styled with the help of CSS2 ::before and ::after generated content and the usual dose of CSS3 transition, shadows etc. When the form is submitted, each selected checkbox or radio value will be passed along like with their regular counterparts.


The CSS:

Note: The check mark seen inside the checkbox replacement is a CSS icon font from Font Awesome. We specify the unicode of the desired font symbol inside our CSS to show it, in this case, a check mark:

label.toggler::after{ /* check mark */
content: '\f00c'; /* fontAwesome icon font unicode. See for others */
left: 3px;
top: 3px;
font: bold 18px FontAwesome;
color: #1B4977;
width: 0; /* hide check mark initially */
text-shadow: 0 0 2px #eee;
overflow: hidden;

 Click here to see the full list of Font Awesome's font unicode values.


Code Info

Rate this code:

Date Posted: 02/04/2015

Revision History: None

Usage Terms: Click here

Copyright 2006-2016 Dynamic Drive