Center Page Content Horizontally using Div with CSS

Posted by Aamir Hasan on ASP.net Weblogs See other posts from ASP.net Weblogs or by Aamir Hasan
Published on Thu, 18 Mar 2010 12:48:00 GMT Indexed on 2010/03/18 20:51 UTC
Read the original article Hit count: 414

Filed under:
|
|

Center your website content to create equal sized Space from  the left and right using css. Horizontally centered by setting its right and left margin widths to "auto". This is the preferred way to accomplish horizontal centering with CSS. Create a warpper div which will hold your content div and then give it a margin:auto attribute which will bring your warpper div into center of page.


<html>
<head>
<title>Center Page Content Horizontally and Vertically using Div with CSS </title>

 <style type="text/css">
body{background-color:#eaeaea;}
  #wrapper {width: 777px;margin:auto}
  #content{background-color:#00FF00;min-height:400px;}
  </style>
  </head>
  <body>
  <form id="form1" runat="server">
  <div id="wrapper">



 <div id="wrapper">

  <div id="content">
  Welcome to Studentacad.com
  </div>


  </div>
  </form>
  </body>
</html>

© ASP.net Weblogs or respective owner

Related posts about ASP.NET

Related posts about html