Center a form using css - HTML CSS CSS Form

HTML CSS examples for CSS Form:Form

Description

Center a form using 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">
form {<!--  w  w w  .j  a v  a  2  s . c o  m-->
   width:301px ;
   margin:0 auto;
   border:4px solid Chartreuse;
   padding:11px;
}

label {
   text-align:right;
   width:100px;
}

input {
   margin-left:11px;
}

label.check, label.radio {
   text-align:left;
}
</style> 
 </head> 
 <body> 
  <form action="#"> 
   <label for="name">Lorem ipsu</label> 
   <input type="text" name="name" id="name"> 
   <br> 
   <label for="email">Lorem ipsum</label> 
   <input type="text" name="email" id="email"> 
   <br> 
   <input type="checkbox" name="subscribe" id="subscribe"> 
   <label for="subscribe" class="check">Lorem ips</label> 
  </form>  
 </body>
</html>

Related Tutorials