I use included files for my header and footer. I am unable to get my pages to center. I have tried throwing the cneter comands around many differant ways but I can never get more than the header, footer, and title to center; then the rest of the page alignes left. I am a Mac user, but i view my page on both a Mac and pc to make sure everything laysout correctly. Can anyone help with a simple or even not so simple way to center all my pages perhaps with an add-on to my CSS library? I can't do live links so visit the URL below to see the site and check out the code or whatever. Thank you, http://www.onlinepokerplayersguide.com
The best way to center a page is to use a 3 column layout. The outside two are set in width and the centre column auto adjusts to the screen size. View my home page for an example: Wesley Warren
Simply wrap the page in a div, or use your existing outer wrapper. #wrapper { margin: 0 auto; } Code (markup): IE will not work unless you have it in standards mode, by using a proper and complete DTD. cheers, gary
i'd use a div container for the whole site with: margin-left: auto; margin-right: auto; and it will hopefully be centered
I have had the same issue, and resolved it after much frustration, but putting it in its own div, and centering the div. What I found was that if it wasn't seperated out, it tended to get clusted with another portion of the site, say the content above it, and take its attributes.
body {text-align:center;}/*For IE to center a page*/ #container {margin:0 auto; text-align:left;} <body> <div id="container"> ... Your Code </div> </body> Will create a full centered page.
May I suggest you add an extra div which starts before the header and ends before </body>. Call it wrapper so the XHTML is - <div id="wrapper"> </div> <!-- wrapper --> and the CSS is - #wrapper { text-align: left; margin: 0 auto; } Make sure that you add this line to the body element in the CSS - body { text-align-center; *The rest of your CSS * } So that it will centre correctly in IE.
Failing to specify the width is the most common mistake when centering blocks of stuff. The css should look like the following: margin-left: auto; margin-right: auto; width: 774px; That will work for div and other properties. Choose a width small enough to not create a horizontal scroll bar when viewing at 800 x 600. The width above, 774 pixels, works when there are no other properties squeezing things down. Sometimes a smaller number is needed.