Aligning a floated div to the parent div - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Float

Description

Aligning a floated div to the parent div

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">
body {<!--from   ww  w .j  ava  2  s. c o  m-->
   width:701px;
   margin:21px auto;
}

#container {
   border:6px solid Chartreuse;
}

#firstDiv {
   border:6px solid yellow;
   width:251px;
   float:left;
}

#secondDiv {
   border:6px solid blue;
}
</style> 
 </head> 
 <body> 
  <div id="container"> 
   <div id="firstDiv">
     FIRST Div inside CONTAINER 
   </div> 
   <div id="secondDiv">
     SECOND Div inside CONTAINER 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials