Subscribe

Cross Browser Minimum Height (CSS)

A issue in my coding life is dealing with IE6 and making things work in it and Firefox (among other browsers). One thing I’ve learned to deal with successfully is putting minimum heights on DIVs. Some people may put a “spacer” image or DIV inside the parent DIV to stretch it out. The problem with that, is sometimes it can be buggy.

Here’s my solution:

#div_name {
    min-height:500px;
    height:auto !important;
    height:500px;
}

Firefox will go off of the min-height property, however, IE will ignore that and will render the element according to the height property. The keyword auto will automatically extend the height depending on what is inside the div. The !important tag is used to set a higher priority to the height, so that it is executed when height of the page exceeds 500px.

Author: Adam Parker

Enjoy this Post? Share it on your favorite social bookmarking site...

 

Submit to Mixx Submit to StumbleUpon Submit to Delicious Submit to Digg

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

8 Comments

Tiffany S.

September 2nd, 2009

Thanks! Helpful for sure.

moon

October 30th, 2009

The order count as well.
It works for me only when 'min-height' comes after 'height'

height:500px
min-height:500px;
height:auto !important;

[...] Cross Browser Min-height [...]

[...] Cross Browser Min-height [...]

[...] Cross Browser Min-height [...]

[...] Cross Browser Min-height [...]

[...] Cross Browser Min-height [...]

mathetos

January 24th, 2010

worked perfectly the first time…. Thanks! Seriously, I wish all hacks were so straight forward and reliable.

Leave a Reply

Related Posts

Check out some more great tutorials and articles that you might like.