Align a radio button's text under the button itself - HTML CSS CSS Form

HTML CSS examples for CSS Form:input radio button

Description

Align a radio button's text under the button itself

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

form {<!--from w  w  w . j a v a2  s .  c om-->
   width: 100%;
}
div.radio-box {
   width: 100px;
   display: inline-block;
   margin: 5px;
   background-color: yellow;
}
.radio-box label {
   display:block;
   width: 100px;
   text-align: center;
}
.radio-box input {
   width: 20px;
   display: block;
   margin: 0px auto;
}


      </style> 
 </head> 
 <body> 
  <form action=""> 
   <div class="radio-box"> 
    <input type="radio" name="sex" value="male"> 
    <label>Male</label> 
   </div> 
   <div class="radio-box"> 
    <input type="radio" name="sex" value="male"> 
    <label>Male</label> 
   </div> 
   <div class="radio-box"> 
    <input type="radio" name="sex" value="male"> 
    <label>Male</label> 
   </div> 
   <div class="radio-box"> 
    <input type="radio" name="sex" value="male"> 
    <label>Male</label> 
   </div> 
  </form>  
 </body>
</html>

Related Tutorials