I'm working on a site which has a content area width of 960px , so it fills a fullscreen 1024 x 760 browser (with vertical scrollbar) almost completely. My problem is that it needs a shadow effect (for larger screen resolutions), which I'm achieving by using a wrapper div with vertical tiled background image. This div however is obviously wider than will fit on the screen at 1024 x 768. I can't get the content div centered in ie unless I use text-align:center. I'm just wondering if this is a valid solution or if I'm missing something. Thanks for any suggestions. here's the code: <html> <head> <style type="text/css"> body {background:#000; margin:0; padding:0; text-align:center;} #outer {margin:0 auto; background:url(shadow.jpg) repeat-y center top;} #inner {margin:0 auto; width:960px; background:#b00; text-align:left;} </style> </head> <body> <div id="outer"> <div id="inner"> inner div </div> </div> </body> </html> Code (markup):
Unfortunately due to IE's quirks, that is a necessary and valid solution. If there's another, I'm not aware of it. Personally, it's the one I use.
If you don't care about anything before IE6, INCLUDE A DOCTYPE - IE from version 6 on WILL center yer elements if you just take it out of quirks mode by including a valid doctype. Though I usually include text-align:center on my BODY tag because I still have clients who want IE 5.x support. (Though I'm increasingly able to talk them out if it - it's only one line of code)