Align label and input - HTML CSS CSS Form

HTML CSS examples for CSS Form:input label

Description

Align label and input

Demo Code

ResultView the demo in separate window

<html lang="en">
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
 </head> <!--  w w  w.ja v a 2s.com-->
 <body> 
  <meta charset="utf-8"> 
  <style>
#new-thing {
   width:451px;
}

#new-thing label {
   clear:left;
   float:left;
   width:121px;
   font-weight:bold;
}

#new-thing input {
   float:left;
   width:251px;
   margin-bottom:.6em;
}
</style> 
  <div id="new-thing"> 
   <form> 
    <label for="name">Lorem ipsum</label> 
    <input id="name"> 
    <label for="first-thing">Lorem </label> 
    <input id="first-thing" style="width:6em;"> 
    <label for="second-thing">Lorem i</label> 
    <input id="second-thing" style="width:6em;"> 
   </form> 
  </div>  
 </body>
</html>

Related Tutorials