Now it’s not surprise to anyone out there that I hate Internet Explorer. No I mean I really hate it! One of the reasons that I hate it so much is that it’s buggy. Call it whatever you want, maybe it’s too forgiving on bad HTML or CSS, but whatever their intentions are (forgiving sloppy code or just too lazy to interpret code right) it causes tons of problems.
The Min-Height Problem
I know a lot of you have had this problem in the past. It’s gotten so bad for me that, at one point, I’ve just stopped using them. Bottom line, Internet Explorer pretends it doesn’t see the min-height property. It uses the regular height property as a min-height. Confused? Let me make it a bit simpler:
Firefox
The height property is a fixed size. It doesn’t shrink and it doesn’t expand with content.
The min-height property is exactly what it says: it gives the element a minimum height, but it still expands with the content of the element. It’s perfect for if you have an element that will just look totally ugly if you it’s empty.
Internet Explorer
The height property is interpreted as a minimum height, funny enough. Doesn’t that suck?
IE CSS Min-Height Hack
But here’s the good news, there’s a fix/hack. Now mind you, there are tons of different ways to get around this issue. There’s conditional IE tags, there’s Javascript hacks, etc. I’ll focus on two, which I like. So here’s what we’re working with:
#box {
min-height:100px;
}
Solution/Hack One
Since, IE doesn’t understand min-height, we have to force a regular height on the element that the other browsers can’t see:
#box {
min-height:100px;
}
/* mac hide \*/
* html #box{height:500px}
/* end hide */
To me personally, this feels right (because we’re doing something specifically for IE and hiding it from other browsers), except for one thing: it involves two hacks. As the comments suggest, IE 5 (I think) for MAC does implement the height property correctly. This just gets worse and worse, doesn’t it?
Solution/Hack Two
#box {
min-height:100px;
height: 100px;
}
html > body #box {
height: auto;
}
Here’s the explanation: We set min-height for Firefox (and other well behaved browsers), then we immediately set the height property so that IE can be happy. This has the effect of, essentially, defeating the purpose of min-height for the proper browser. We then use the CSS child selectors (which, conveniently IE can’t see), to set the height back to auto and make everyone happy.
There’s a slight problem when using 100% heights that I don’t really want to get into, but you can see a fix for it here.
Why I love this hack, is because it’s a little bit cleaner. But the really great part about this is that, because we only set height to auto as a fix, we can fix multiple elements all in one line:
html > body #box,html > body #box2,html > body #box3,html > body #box4, html > body #etc {
height: auto;
}
Well folks, there we have it. The nasty subject of CSS hacks. Hope this helps.
Popularity: 61%

I hate IE too! Bleah Bleah Bleah!
colleen, on June 5th, 2008 at 12:10 pm
Another one that I like doesn’t technically involve any hacks at all. I wrap a div around the div and set the heights that way if I REALLY need to have a set height, and just hide the overflow.
Daniel Costalis, on June 7th, 2008 at 12:22 pm
I think #box { height:auto !important; min-height:100px; height:100px; }
does the trick. Firefox shouldn’t apply the height 100px rule due to the unsupported in ie6 !important declaration.
Abba Bryant, on August 12th, 2008 at 12:03 pm
Hello. There is a much simpler solution for this:
#div {
min-height: 100px;
_height: 100px;
}
IE will read “_height” property, other browsers won’t.
Luis, on September 11th, 2008 at 1:33 pm
Hack 2 saved my bacon! until i read the comment above, and then i used that instead… er. so i guess what i’m trying to say is, very useful page all-round..?
Beth, on September 18th, 2008 at 2:29 pm
This is looking pretty simple but what happens if the height of the DIV Exceeds its limit for example we have set height:100px; this will be assigned to IE. If the content of the DIV exceeds means what would be the result.
Looking for your reply.
rskbuvan, on September 26th, 2008 at 10:40 am
Trackbacks & Pingbacks
IE Hack: CSS Centering - Another Reason I Hate Internet Explorer | Web Development 2.0: Web Design, CakePHP, Javascript, on June 9th, 2008 at 7:32 am
Leave a Reply (I Follow)
Popular Posts
Recent Posts
Tags
Add new tag Ajax apache auth backup bake bakery Blog browser CakePHP calendar cookie cron CSS database date design domain Fast CGI firefox form free ie internet explorer JavaScript jquery Linux mootools MySQL PHP prototype ruby on rails School time tutorial wamp wordpressCopyright © Web Development 2.0. All rights reserved. Monitored by Uptime Dog