Log in

View Full Version : need help with css margin



doforumda
05-28-2011, 12:31 PM
hi
I am trying to put content_wrapper div in the center of the browser. It works for Chorme, Firefox, Opera, safari but it does not work for IE 8. Here is my css


body { font-size: 12px; font-family: Arial, Helvetica, sans-serif }
#content_wrapper { width: 1000px; margin: 0 auto; border: 1px solid #000000 }

Help Please

jscheuer1
05-28-2011, 02:55 PM
Using margin: 0 auto; when specifying the width is the way to do it. In IE though this also requires a standards invoking DOCTYPE. I usually use the HTML 5 DOCTYPE. You can use any of the standards invoking DOCTYPES that can apply to your page that are covered here (the HTML 5 one is first):

http://www.javascriptkit.com/howto/doctype.shtml

In case you don't already know, a DOCTYPE is the very first thing in the HTML source code of a page, right before the opening <html> tag, even before any comments. It tells the browser certain things about how to render the page. It tells some browsers more things than others (example IE), but it tells all browsers some things. So the rest of your page may or may not render differently after invoking standards. If it does, it's generally better to fix that than to revert to non-standard (Quirks) mode, as quirks vary much more widely among browsers than do standards.