This site will look better in a browser that supports Web standards, but it is accessible to any browser or Internet device.

November 18, 2005

1993
2001
2002
2003
2004
2005
January
February
March
April
May
June
July
August
September
October
November
Su M Tu W Th F Sa
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30      
December
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022

I Love Fixing Broken Web Browsers

A bug that had plagued my own Web site since the 5.0 redesign surfaced when I rewrote the company site: Every once in a while, Internet Explorer would just fail to show the page's content. Which is kind of a problem, y'know.

Basically, it boils down to the fact that IE is broken. The fix, for those that care, is to exploit three more bugs.

/* \*/
* html div {height: 1px;}
/* */

This gibberish that I found on the Web today is what keeps me from driving to Redmond, because it actually works. Basically, IE chokes when the CSS layout gets too complex, because things don't have explicit heights. This is a problem, because things like paragraphs can't have defined heights.

But then the first bug comes along and helps us out. IE gets the height command wrong. If I assign something a height, it's that tall no matter what. IE just treats it as min-height, which sets a minimum then lets the contents run as long as they want. So setting the height to 1 pixel doesn't really do anything. In IE. Every other browser would see that and show you, at best, the very tops of capital letters.

So then we exploit another of IE's bugs, this time in its CSS reading code. The first /* opens a comment. The \*/ that follows it doesn't close the comment in non-IE browsers but does in IE. So only IE pays attention to the next line, which is where we work our voodoo. The /* */ after the hack just gets every browser back on the same page, so to speak.

But now we have another problem. Mac/IE doesn't have the original bug so we don't want it to see our hack. But it also has that flawed reading code. But it doesn't have IE's last bug, that we can now use to restrict our hack to only Win/IE. * html cannot possibly match anything, because <html> has no parent element. Thus the statement is invalid. Win/IE doesn't care, though, so it happily applies the rule. Mac/IE at least has the good sense to ignore the impossible, so only our true target gets the hack.

Two wrongs don't make a right. As you can see, it actually takes three.

This page's URL is http://jasonfleshman.org

This page last updated Jul 19, 2019 3:34:19 PM.