margin: 0 auto; not centering in Internet Explorer? margin: 0 auto; not centering in Internet Explorer?

The other day, I had chopped up a design.  Sliced and diced if you will.  I proceeded to creating the HTML once all of the images were sliced up.

Things were going great.  As per usual I began designing in Mozilla to use Firebug to tweak the CSS and HTML.  Once I finished the design, I proceeded to test in Chrome, Safari, and of course, Internet Explorer.

Every browser but Internet Explorer was working perfectly, what gives?

The worse part is, I know I've had this problem before.  If you're like me, you may have worked on 100s of different projects and they all start to blend together because you've done this here and that there.

Luckily, I was actually able to remember what the problem was!  I forgot my DOCTYPE at the top of my file:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"   "">

Add that bad boy to the top of your file, reload and voila, Internet Explorer now loads the web site like every other browser does!

This may not be the only issue that you see without a DOCTYPE and Internet Explorer.  Sometimes it may be a spacing issue, things wrapping incorrectly, etc...  The route of the cause will, most likely, be a missing DOCTYPE.


Published on Sep 18, 2009

Tags: The Ultimate CSS Tutorial for Beginner Programmers | margin: 0 auto

Related Posts

Did you enjoy this article? If you did here are some more articles that I thought you will enjoy as they are very similar to the article that you just finished reading.


Learn how to code in HTML, CSS, JavaScript, Python, Ruby, PHP, Java, C#, SQL, and more.

No matter the programming language you're looking to learn, I've hopefully compiled an incredible set of tutorials for you to learn; whether you are beginner or an expert, there is something for everyone to learn. Each topic I go in-depth and provide many examples throughout. I can't wait for you to dig in and improve your skillset with any of the tutorials below.