Replace radio buttons with images - HTML CSS CSS Form

HTML CSS examples for CSS Form:input radio button

Description

Replace radio buttons with images

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">

input[type="radio"]{
   display: none;
}
input[type="radio"]+label{
   background: url('https://www.java2s.com/style/demo/Safari.png') left center no-repeat;
   padding-left: 30px;
}
input[type="radio"]:checked+label{
   background: url('https://www.java2s.com/style/demo/Google-Chrome.png') left center no-repeat;
   padding-left: 30px;
}


      </style> 
 </head> <!--from www . java 2s  . co m-->
 <body> 
  <fieldset id="gender"> 
   <input type="radio" checked name="apsgender" id="male" value="1"> 
   <label for="male">Male</label> 
   <br> 
   <input type="radio" name="apsgender" id="female" value="2"> 
   <label for="female">Female</label> 
  </fieldset>  
 </body>
</html>

Related Tutorials