I’ve been doing a bit of web design in my spare time lately and before long I came across the issue of using margin: auto; in my stylesheet not working in internet explorer. Meeehhhh! I couldn’t be doing with that and given that the best way to attack an unknown problem is to search for knowledge I hit google (not literally of course).
Turns out, that you can force Internet Explorer (and other browsers) to parse your cascading style sheets strictly by using a strict doctype definition. I used the one below for my project;
<!DOCTYPE html PUBLIC “-//W3C//DTD HTML 4.01//EN” “http://www.w3.org/TR/html4/strict.dtd”>
This was news to me, but welcome, because now I can center my divs in a cross-browser compatible way and move on to other problems like why background images for input elements aren’t loading on https pages (please let me know if you know why).
Oh and if you’re interested in more information http://hsivonen.iki.fi/doctype/ has a useful table of which doctype definitions trigger what behaviour in the popular browsers.
June 10th, 2008 at 8:50 pm
[...] Go to the author’s original blog: Getting Margin:Auto; To Work in Internet Explorer [...]