position two boxes to align one to top left corner - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:2 Column

Description

position two boxes to align one to top left corner

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">
.outer {<!-- w w w .j  a va  2  s .com-->
   position:relative;
   width:401px;
   height:401px;
   background-color:Chartreuse;
}

h1 {
   color:yellow;
}

.inner {
   padding:9px;
   position:absolute;
   top:0;
   left:0;
   background-color:blue;
}
</style> 
 </head> 
 <body> 
  <div class="outer"> 
   <div class="inner"> 
    <h1>Lorem ipsum</h1> 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials