IE6 Double Margin Bug Fix
I know this doesn’t pertain to anyone reading this except me I’m sure. I’m simply writing this up so I’ll have a reference for later when I encounter the same problem in my wonderful world of css. Nonetheless, if you have a floated element such as a div and you place margin-right or margin-left on that element, our most beloved Internet Explorer 6.0 will double that margin value, causing havoc in your html layout. To fix this simply add display:inline; to your floating element. Bah Boom!

Stephane Koenig - April 26th, 2007 at Apr 26, 07 | 2:00 pm
Thank god you wrote that up.
Thank you.
~ Steph
Martin Przybyla - May 26th, 2007 at May 26, 07 | 1:21 pm
Amen, brother. Thanks for sharing.
Ben - May 31st, 2007 at May 31, 07 | 5:14 pm
Yes! Thanks for sharing. You saved me.
Jeremy - June 8th, 2007 at Jun 08, 07 | 5:25 pm
Thank you! Until now I’ve always used:
margin-left:20px;
_margin-left:10px;
First one gets read by IE7 and FireFox. Second gets read by IE6. Awesome!
Bonny - June 21st, 2007 at Jun 21, 07 | 3:34 pm
Jeremy’s method of above is super helpful when you have a DIV that is set to display:none; but needs the IE6 fix ! You Rock!
James - July 17th, 2007 at Jul 17, 07 | 2:34 pm
Whew, that was an easy fix, I was expecting a much more complicated fix like all the others. Thanks a million.
James - July 17th, 2007 at Jul 17, 07 | 2:36 pm
And Jeremy — you just fixed the other one of my bugs. Thanks for the tip!
Steve - October 1st, 2007 at Oct 01, 07 | 12:30 pm
My God fella, just spent 3 hours trying to work out why my page was getting chewed up by IE6, then I found your answer, thankyou!
ryan - October 4th, 2007 at Oct 04, 07 | 3:16 pm
You lost me at ‘beloved’ :P
Haha! But in all seriousness… that’s a very helpful tip. Thanks.
Vitor Lopes - October 9th, 2007 at Oct 09, 07 | 8:01 am
Dude… thank you so much!
IE6 should be banned.
jimmy - October 9th, 2007 at Oct 09, 07 | 9:47 am
Thanks!
Dave - October 13th, 2007 at Oct 13, 07 | 4:00 pm
I can only agree with the ones above: Thank you so much!
//Dave
Bart-Jan - October 16th, 2007 at Oct 16, 07 | 7:34 am
So much better than writing up IE specific hacks every time, thanks a lot!
Peter - October 22nd, 2007 at Oct 22, 07 | 1:18 pm
My god this is a life saver :D I hate Exporer 6 with a passion but so many of my clients still use it, this really makes my work so much easier ^^
Krystian - October 25th, 2007 at Oct 25, 07 | 9:04 am
THANK YOU!
Paul Koppen - November 6th, 2007 at Nov 06, 07 | 4:24 pm
Whish all Google #1 hits were this short and this accurate!!
You’re my hero for today.
andy - November 8th, 2007 at Nov 08, 07 | 7:42 pm
Definitely a helpful fix, thanks.
Atze - November 13th, 2007 at Nov 13, 07 | 6:18 am
i was nearly goin’ nuts with IE6 - until i figured out that the margin was exactly doubled…
so a “IE6 double margin” in google brought me to your “anyone reading this except me” :D post.
amazing - i don’t like those * html etc. hacks in my stylesheets.
your solution works like charm :)
Ashish - November 14th, 2007 at Nov 14, 07 | 10:58 pm
Hi,
In my case, I have floated the left element and the right content is relative positioned with a left margin. The left sidebar includes “display: inline” Still, IE 6 shifts the right element below the left. Any clue why?
Thanks a ton.
Ashish
Patrick - November 18th, 2007 at Nov 18, 07 | 10:08 am
Hi there,
I was going nuts too, this saved me. Thanks for the fix!
Keith - November 20th, 2007 at Nov 20, 07 | 6:29 am
hey dude
more love to you man, easy fix, thank god i found this page haha
russellnation - November 23rd, 2007 at Nov 23, 07 | 10:23 pm
sweet just what i needed
Roger Gordon - November 26th, 2007 at Nov 26, 07 | 1:53 pm
I encountered this before and though I must be going crazy. So tonight I encountered the same problem, tested and measured it, and yip, IE6 does indeed double the margin. What the heck?
Anyway, thanks for this elegant fix. I was about to revert to a new IE6 style sheet, but will probably be able to retain just the one now.
Ian Atkinson - December 11th, 2007 at Dec 11, 07 | 2:39 pm
Googled ‘ie6 double margin’ and got this … which works like a charm! Top man!
Ian.
Steve - December 14th, 2007 at Dec 14, 07 | 4:06 pm
Same as all the others, you’re a life saver.
Kai Chan Vong - December 15th, 2007 at Dec 15, 07 | 5:44 pm
Thanks. Just spent ages thinking I was going out of my mind.
Justin - January 2nd, 2008 at Jan 02, 08 | 7:58 pm
Thanks for this.
Bryony - January 18th, 2008 at Jan 18, 08 | 10:36 am
Kudos to you!
Thanks muchly :)
Rapidz - January 19th, 2008 at Jan 19, 08 | 9:02 am
You sir, are a GOD. Many thanks.
Alexandra - January 23rd, 2008 at Jan 23, 08 | 9:35 am
Wow! Thanks a lot for this!!!!
It saves me lots of hours of pulling my hair ;-)
good work!
greetings from France
Kaloyan - January 23rd, 2008 at Jan 23, 08 | 2:54 pm
Very helpfull, thanks.
Sean - January 29th, 2008 at Jan 29, 08 | 11:31 am
You have saved my scalp many a missing hair.
jp - January 31st, 2008 at Jan 31, 08 | 12:18 pm
Nice one :)
dj - February 3rd, 2008 at Feb 03, 08 | 7:38 pm
Fantastic. HOWEVER, and I’d love to have someone confirm this, but until I put the display:inline rule *above* the margin rule, IE6 still doubled up on me.
If this is true, I wonder what other nuances and bugs are caused simply by the ordering of style rules? Perhaps I haven’t been crazy all of this time trying to devise the best order to type out my styles…
Anyway thanks A MILLION for this!
Thilina - February 4th, 2008 at Feb 04, 08 | 12:26 am
awesomesauce! ty!
George Wiscombe - February 7th, 2008 at Feb 07, 08 | 7:01 am
This is what i love about blogs…
You use it as a tool to remember something and in turn help thousands!
Adrian Diaconescu - February 7th, 2008 at Feb 07, 08 | 10:02 am
Thanks Jayme! You just saved me a lot of time.
Jaison James - February 13th, 2008 at Feb 13, 08 | 12:43 am
nice :)
volker - February 28th, 2008 at Feb 28, 08 | 9:55 am
DANKE from Germany!
Ryan Covert - March 7th, 2008 at Mar 07, 08 | 9:18 am
Thank you! I, too, was thinking that the problem wasn’t as easy as this. In the past, some of the floating problems in IE6 were fixed by simply wrapping the div with a nameless container div.. but that didn’t help this time around. your “Display: inline;” did the trick.
Does anyone know “why” this works and “why” IE6 doubles the margin, though?
Thanks again!
Alexander Pavlov - March 13th, 2008 at Mar 13, 08 | 10:18 am
Thanx alot, i’ve been almost crazy about that!
Anders - March 14th, 2008 at Mar 14, 08 | 6:01 am
Quick and clean - perfect!
Keith Foster - April 3rd, 2008 at Apr 03, 08 | 4:01 am
Simple… I love it.
I was aware of the double margin issue… and was just doing a quick search to see what the hell was actually going on with IE6.
I was just about to do a *margin-left, thanks for the non hacky solution.
Brooks - April 3rd, 2008 at Apr 03, 08 | 5:29 am
Oh joy,
love it thank you very much!
BJ - April 8th, 2008 at Apr 08, 08 | 9:31 pm
Thanks. I thought I just needed some sleep. Damn IE6!
DanDan - April 9th, 2008 at Apr 09, 08 | 11:53 am
I would like to award you the IE destroyamagator award. Way to go.
Russell Bishop - April 16th, 2008 at Apr 16, 08 | 7:24 am
My god sir, you are my hero :D
Was working late for a client - deadline tomorrow - going crazy, then I googled ie6 double margin and found this LOVELY fix.
Ken - April 19th, 2008 at Apr 19, 08 | 3:45 am
Works like a charm. This problem took me hours! thanks
Patrick O'Connor - April 22nd, 2008 at Apr 22, 08 | 9:18 pm
You are a godsend! a simple Google search brought this up and saved me a ton of time and frustration!
Thanks for this great reference!
Paff - April 24th, 2008 at Apr 24, 08 | 3:19 am
Thank You for this very useful and time-saving tip! :)
imran khalid - April 24th, 2008 at Apr 24, 08 | 9:12 am
I was worried about this problem but you solved my problem…..
Thanks
Pip - April 28th, 2008 at Apr 28, 08 | 2:23 pm
Great tip! Thanks. Saved me a lot of hassle.. :)
Paul Feakins - April 29th, 2008 at Apr 29, 08 | 4:56 am
Microsoft suck.
You rock.
Cheers.
Ben Walker - April 30th, 2008 at Apr 30, 08 | 11:57 am
I love you. Which is more than I can say for IE6. ;o)
Daniel Böcker - May 6th, 2008 at May 06, 08 | 11:28 am
Superior!
Paul Ward - May 8th, 2008 at May 08, 08 | 5:18 am
Many thanks for your post - has ended a couple of hours of hacking around!
James - May 9th, 2008 at May 09, 08 | 5:10 pm
Do you need a job?
Valerie - May 13th, 2008 at May 13, 08 | 1:41 pm
Bless your heart from Durham!
Eddy - May 18th, 2008 at May 18, 08 | 2:41 pm
i love you!
Mody - May 26th, 2008 at May 26, 08 | 6:19 pm
Thank you!
Todd - May 29th, 2008 at May 29, 08 | 10:33 am
Best tip ever.
Eric - May 31st, 2008 at May 31, 08 | 8:06 am
Just for fun I punched “margin double” in Google and found this toward the top. I know IE is horrible, but I thought, “No way, it could be something this obvious.” I didn’t even expect to find a solution. This is just such a great post.
Jonathan - June 1st, 2008 at Jun 01, 08 | 2:30 pm
Woah… I can’t believe that worked.
E Meline - June 9th, 2008 at Jun 09, 08 | 3:44 pm
Bless you kind sir!
Bevi - June 9th, 2008 at Jun 09, 08 | 5:36 pm
IE6… Why???? Why too much people still use it????
Thanx to all the guys than gave some solutions, everyone have his magic ;-)
Mainly thanx to the publisher of the note in the begining, cause the rest not happen
Greetings from Argentina!!!
Jimbo - June 16th, 2008 at Jun 16, 08 | 10:30 am
According to W3C browser statistics, 28.9% of all computers on the web still use IE6. So this is a great tool for helping those of us who hate Microsoft cope. Thanks for the tip.
slarty - June 16th, 2008 at Jun 16, 08 | 6:18 pm
Thanks a lot man, having just finished sorting out transparent PNG problems in IE6 I got to work trying to figure out with the heck was going on with my margins.
Worked like a charm
Daniel Perin Tavares - June 17th, 2008 at Jun 17, 08 | 3:04 pm
Great!!!
Thanks for share!
J0n - June 20th, 2008 at Jun 20, 08 | 7:11 pm
Wow… I love Google and I love YOU!
Stephen Lombardo - June 22nd, 2008 at Jun 22, 08 | 11:37 pm
I’m sure this just saved me an hour+ of hacking… Thanks!
Kris - June 26th, 2008 at Jun 26, 08 | 11:17 am
Worked a charm