Center Page Content Horizontally using Div with CSS
- by Aamir Hasan
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>