Make Radio buttons "pretty" with CSS - HTML CSS CSS Form

HTML CSS examples for CSS Form:input radio button

Description

Make Radio buttons "pretty" with CSS

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
  <style id="compiled-css" type="text/css">

label {<!-- w  ww. j  av  a2 s  .c o  m-->
   display: inline-block;
   cursor: pointer;
   position: relative;
   padding-left: 25px;
   margin-right: 15px;
   font-size: 13px;
}
input[type=radio] {
   display: none;
}
label:before {
   content: "";
   display: inline-block;
   width: 16px;
   height: 16px;
   margin-right: 10px;
   position: absolute;
   left: 0;
   bottombottom: 1px;
   background-color: #aaa;
   box-shadow: inset 0px 2px 3px 0px rgba(0, 0, 0, .3), 0px 1px 0px 0px rgba(255, 255, 255, .8);
}
.radio label:before {
   border-radius: 8px;
}
input[type=radio]:checked + label:before {
   content: "\2022";
   color: #f3f3f3;
   font-size: 30px;
   text-align: center;
   line-height: 18px;
}


      </style> 
 </head> 
 <body> 
  <div class="radio"> 
   <input id="male" type="radio" name="gender" value="male"> 
   <label for="male">Male</label> 
   <input id="female" type="radio" name="gender" value="female"> 
   <label for="female">Female</label> 
  </div>  
 </body>
</html>

Related Tutorials