Forum Moderators: not2easy

Message Too Old, No Replies

How do I center the page on the screen?

         

okrobie

6:31 pm on Feb 20, 2010 (gmt 0)

10+ Year Member



In the old days I was taught to create pages at 100% to fill any screen. Now the screens are so wide that it seems best to create the page at 1000px or so. A 100% page looks too stretched out on a wide screen. My question is how do you center the page on a wide screen once it is reduced to 1000px width. I see it done all the time but I can't seem to do it myself. My page is pushed to the left. What's the secret?

rocknbil

7:35 pm on Feb 20, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Welcome aboard okrobie, no real secret: margin: auto. Although not supported in IE6, the max width property is extremely helpful "these days."

#main {
width: 100%;
max-width: 1020px;
margin:auto;
}

...

<div id="main">
<p>content here</p>
</div>

okrobie

7:55 pm on Feb 20, 2010 (gmt 0)

10+ Year Member



Thank you Rocknbil, it works great. I'll be back for sure. This is a great forum.:)