How to fix IE 6 and overflow: hidden

PostApr 26th, 2007 | Comments (12)
I figured out this morning that IE 6 apparently has issues with "overflow: hidden." IE 6 completes ignores the overflow setting unless the surrounding element has a fixed width.

Here is an example of how it looked in IE 6 to being with.

I've drawn a red dotted line to indicate where the right boundary of the surrounding div is supposed to be.



As you can see, the long titles are pushing against the right side of the parent div and causing it to expand instead of getting cut off.

Giving the parent div a setting of "width: 100%" causes the text to be hidden correctly, but the long titles are still pushing the right side out:



However, if you give the parent div a fixed width setting "width: 300px," IE 6 behaves correctly:



As you can see, the inner div isn't pushing the right side of the parent div anymore.

Comments

maritnJul 28, 2008
Thanks, you are a life saver. I didnt realise the problem was so simple.
AlexanderDec 19, 2008
Thank you so much for a wonderful simple solution.
I tried this on the wrapper but it wasn't enough. You also need to set position relative on the element that has overflow: hidden.

BTW. didnt need to set px width. worked fine with only 100%. This didn't push my site out on the side.

IE <3
ArienMar 2, 2009
Thank you, Dedric [previous comment], i was battling with this for hours, and a simple position: relative did the trick.;]
amy vargaApr 2, 2009
IE 6 position relative is a good call!

Thanks
Andrew MabbottApr 30, 2009
Thanks. Helped me to solve a similar problem I was having in the vertical direction.
DavidMay 15, 2009
Thanks! Glad this was the first link I clicked on!
DannyJun 2, 2009
Thanks guys.
The width attribute didnt fix it for me either. For me I only needed the position:relative.
ScottSep 2, 2009
Thanks. Adding 'overflow: hidden' on the container (mask) div worked for me...
ScottSep 2, 2009
Bah, meant to say, adding 'position: relative' on the container div worked for me too...
Oliver NassarMay 12, 2010
Sweet! Thanks dude.
iaroAug 4, 2010
You saved me. Thanks a lot.

Post a comment

Name
URL
Email
Comment