Solution (Pseudo Bug)
Date of the Solution
Sun Aug 9 06:42:54 2009
Fixed Versions
All of the affected
Description
If you have a sharp eye, you probably spotted the problem already - no DOCTYPE! What does this mean? Affected IEs go into quirks mode and start rendering like their old ancestors because they think your page was coded long time ago and isn't ready for the newer, less buggy rendering.
- HTML Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>No Auto Margin Center Bug Fixed Demo - hasLayout.net by Zoffix Znet</title>
<h1>Center Meh!</h1>
- CSS Code:
h1 {
width: 100px;
margin: 0 auto;
}
We've added the doctype and now everything works as it should. Keep in mind that having comments and other junk before the doctype can also trow IE in quirks mode. A simple test to see which mode your page is in, simply run this code in your location bar: javascript:alert(document.compatMode)
. If the message says BackCompat, it means quirky behaviour.