vertically and horizontally center element in its container - HTML CSS CSS Layout

HTML CSS examples for CSS Layout:Center

Description

vertically and horizontally center element in its container

Demo Code

ResultView the demo in separate window

<html>
 <head> 
  <meta name="viewport" content="width=device-width, initial-scale=1"> 
 </head> <!--from   w ww.  ja  va 2s.  c  om-->
 <body> 
  <div style="display:table;height:200px;width:500px;"> 
   <div style="display:table-cell;width:100%;vertical-align:middle;text-align:center;">
     Lorem ipsum do 
   </div> 
  </div>  
 </body>
</html>

Related Tutorials