Reality.sys corrupted! Universe halted! Reboot?

Internet Explorer 7 in quirks mode Internet Explorer 7 in quirks mode

Internet Explorer 7 is out. I was hoping Microsoft will admit that they can’t make a decent browser and that IE7 will never see daylight. But, unfortunately, that never happened. And now this so called “web browser” is hitting the web, so we, the ones working in the website making business, have more work to do because our sites will require testing in IE 7 too. But there’s a way to make things easier.

New browser, new problems

Of course IE 7 has its problems and doesn’t respect the standards. But it has other problems than its predecessors. Microsoft has worked really hard for many years to discover new ways to make a browser suck. But while the older bugs are well known and documented, with lots of workarounds, the new ones may strike you when you least expect it. And figuring them out might take days. Suffice to say, the old ones are better.

All browsers, IE included, have a so called quirks mode. When in this mode, a browser renders a page in a way that it’s backwards compatible with older webdesign trends, opposite to the “standards mode”, when the page is rendered strictly according to the specified standard. But since IE has some crazy standards, based on the planets’ alignment, trying to make use of them will almost everytime result in failure. So the conclusion is simple: IE in quirks mode means less headaches.

Forcing IE 7 in quirks mode

So far, all you had to do in order to force IE in quirks mode was to write the XML prologue above your DOCTYPE definition. Like so:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

but this was fixed in the new version of IE. Instead of fixing some real bugs, they’ve fixed this. I LOVE YOU MICROSOFT! Fortunately there still is a way to force Internet Explorer 7 in quirks mode: add a HTML comment between the XML prologue and the DOCTYPE. Such as:

<?xml version="1.0" encoding="UTF-8"?>
<!-- IE sucks! -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Now IE7 will render in quirks mode, so most of the IE 6 CSS workarounds will work. I say most because I’ve encountered some problems with position: relative, but these can be fixed with some conditional comments.

Don’t worry about other browsers, they will ignore the comment, like they are supposed to. So will the W3C Validator and you can still use those XHTML Valid badges. And I don’t think that this will affect search engines in any way, as crawlers also ignore the comments.

similarposts (presented by Monkey)

Monkey

comments...comments...3comments

  1. MihaiNo Gravatar said:

    Yep! They really try to be stupid. Geez…I always loved corporate jokes, so <!– IE sucks! –> is a hit! Thanks for figuring that out!

  2. michaelNo Gravatar said:

    It can however be forced into quirk mode by including a comment before the DOCTYPE declaration like so:
    <!–quirks mode for ie7–>
    <!DOCTYPE html PUBLIC
    “-//W3C//DTD XHTML 1.0 Strict//EN”
    “http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd”>

  3. TudorNo Gravatar said:

    Thanks for sharing that. I was using the XML prologue before IE 7, for me it’s a habit now. That’s why I’ve put it there.
    But it’s good to know that it can be done without it…

yourReply