When "line boxes"- invisible "anonymous" boxes that contain inline text, images, and anything else that is declared 'inline' - are adjacent to a float, a 3px margin appears between the line-box and the edge of the float. (The 3px margin disappears as soon as the content clears the float, causing a 3-pixel "text jog".)
Apply the Holly Hack or use the zoom property.
This issue was originally documented by Holly Bergevin and Big John Gallant on positioniseverything.net.
Fixing this 3-pixel text jog that's introduced when line boxes with inline elements are adjacent to a float in IE/Windows requires giving the paragraph an explicit dimension, which prevents IE/win from adding the 3px space. However, adding a dimension (width or height) also throws IE into a proprietary float model- and the element will act much like a float, displaying next to the real floated element, as opposed to letting the float overlap it.
The old (pre-IE7) solution for this bug, and several others, was the Holly Hack. However, the Holly Hack relies on buggy behavior that is no longer present in Internet Explorer 7 -- and using it can cause things to go a bit haywire. Instead, use an Internet Explorer Conditional Comment (IECC) after your CSS file in the head of the document to apply zoom: 1 to the line box in all versions of Internet Explorer. This will give the box the "layout" it needs to prevent the three-pixel gap, without throwing Internet Explorer into its proprietary float model.
<!--[if IE]>
<style type="text/css">
.mybuggyelement { zoom: 1;}
</style>
<![endif]-->
A class doesn't have to be used however. You can also use the affected ID or descendent selector, or even a group of selectors, that target the element itself. For instance, if the problematic elements were the #mainContent and #sidebar1 divs, you could use the following:
<!--[if IE]>
<style type="text/css">
#mainContent, #sidebar1 { zoom: 1;}
</style>
<![endif]-->
Text ID: THREE_PIXEL_JOG
To add a comment, please Log in.
Struggling Too
by drwtf1012 on December 30, 2008
my error is occurring with a flash movie in my header. I've added
<!--[if IE]>
<style type="text/css">
/* hide hack from Mac-IE5 \*/
* .thrColFixCtr #header { height: 1em; }
/* end hiding */
</style>
<![endif]-->
<!--[if IE]>
<style type="text/css">
/* place css fixes for all versions of IE in this conditional comment */
.thrColFixCtr #sidebar1, .thrColHybHdr #sidebar2 { padding-top: 30px; }
.thrColFixCtr #container { zoom: 1; padding-top: 15px; }
/* the above proprietary zoom property gives IE the hasLayout it needs to avoid several bugs */
</style>
<![endif]-->
in my header with no results.
Another issue has arisen in that when recreating the html with a different web host server, none of the flash appears in the browser.
Help anyone?
Thanks.
i'm struggline
by Angell EYE on October 22, 2008
for some reason i'm struggling. anybody wanna do a screen-share with me??? :)
good fix
by greycell on June 24, 2008
insert the css rule before your head tag. rename the class (.mybuggyelement ) as needed and then apply the class to instances of divs containing bugging elements. works fine
Where does the zoom property go?
by gabemejia on March 5, 2008
here is where I get the Three Pixel Text Jog error:
<div id="mainContent">
where should I insert the zoom property?
thanks.
confusion
by diver993 on December 23, 2007
Should the hack be in the header or the div tag? So far I agree with delirious19th: it don't work?!?
hack not working..
by delirious19th on December 7, 2007
i'm not getting the 'zoom as an unspecified property' error but this hack still doesn't work. i would just use colencleaner's solution but i've already got several divs. eh. i'm sure after playing around with it some more i'll have it. i was just wondering if anyone else was having the same problem.
To clarify for the comments below:
by stefsull on November 29, 2007
@Brian - yes, you're correct. In fact, it SHOULD be applied to the container, not to the p elements inside. It is the container that will display the buggy behavior.
@macca63 - Internet Explorer Conditional Comments (IECC) are placed into the head of your document (syntax documented in the article above).
@colencleaner - the above syntax should work in the head of your page and should not give you a comment about the zoom property if done correctly. Perhaps if you open one of the CSS layouts in DW and look at the IECC there, you can see where your syntax may have gone wrong? (Most have an IECC with a zoom declared on the #mainContent div.)
HTH,
Stephanie Sullivan
got it
by colencleaner on November 27, 2007
ok so i didn't use what was listed here but I got the error to go away. Not sure if it works fully. But I just created a div around the text that was getting all crazy. Kind of hard to explain but It no longer gives me the error :D
do what now?
by colencleaner on November 27, 2007
Ok so I tried to apply the IECC hack and all I got was more errors saying that "Zoom" is an unsupported property. I tired 2 ways. The way specified above, I tried in my CSS and the head. Nothing. Can some on give us some better examples of how this is supposed to look?
where to put the code
by macca63 on November 19, 2007
Hi,
where do i have to put the code <!--[if IE]><style type="text/css"> .mybuggyelement { zoom: 1;}</style><![endif]-->
in the head tag or body tag?
Like to hear a comment
Macca
Additional note
by Brian Crescimanno on January 23, 2007
An addition to my previous comment:
The reason for applying to the container and not the "p" tag is to allow right or left aligned images to flow normally and have the text wrap properly around them in IE. If the fix is applied to the paragraph directly, any images within the text will not be wrapped as expected.
Can be applied to container
by Brian Crescimanno on January 23, 2007
This fix can be applied to the container in a 2-column scenario rather than be applied to the paragraphs. In the following scenario:
<div id="float">This is the left column floating</div>
<div id="main">This is the right column, not floating.
Your CSS can be applied to "main" which will fix all the paragraphs within main:
/* hide hack from Mac-IE5 \*/
* html #main { height: 1em; }
/* end hiding */