Personal tools
You are here: Home Documentation How-tos Fixing invisible or disappearing text and double margins in Internet Explorer
Support

Get Help

Join our chat rooms or support forums if you have more specific questions.

Plone Training
Learn how to design, build, and deploy a website in Plone through one of the numerous Plone training sessions around the world.
Find Plone training…
 
Document Actions

Fixing invisible or disappearing text and double margins in Internet Explorer

This How-to applies to: Any version.
This How-to is intended for: Integrators, Customizers

Internet Explorer has a very serious bug when calculating the height of floating elements, which can cause elements to disappear. Here's a simple way to work around it in any layout, with a special convenience class for Plone - although the approach is valid for any CSS layout.

The problem

Displaying a page in Internet Explorer causes text to disappear, or elements to be wider than their proper width.

There is not general way to fix this problem on a page-wide scale, so you have to test your pages in Internet Explorer and see if they exhibit this behaviour. If they do, you can apply a simple class to that element, and it will behave the way you intended again.

Some examples

Below are a couple of examples of the bug as they normally appear in Plone:

The classic example of disappearing text in Internet Explorer. Here we see that the headline of the Plone welcome page is only visible when selected. The cause of this is a floating element to the right (the default document actions print/send to friend icons in Plone).

A related bug is the double margin bug in Internet Explorer, which is also fixed by applying this CSS trick. Notice the erroneous area on the left side of the board post that shuld not be there. This is caused by the same bug in Internet Explorer that mis-calculates element sized when using floating elements in your layout - in this case the portrait image on the right.

The reason

Detailed explanation can be found in the page about the Internet Explorer Peekaboo rendering bug. I'll mostly deal with how to fix the problem in this how-to, but read this if you are interested in the in-depth technical explanation.

The solution

Plone 2.1 (and later versions of the 2.0 series) contain a CSS class called visualIEFloatFix which applies the so-called "Holly hack" to get around bugs in the Internet Explorer rendering engine.

The rule looks like this:

    * html .visualIEFloatFix { height: 0.01%; }

The * html part is to hide it from Internet Explorer 5 on Mac, which has a totally different rendering engine, and does not exhibit this problem. Additionally, we have structures in Plone that hide this rule from all browsers that are not Internet Explorer (without using browser sniffing), so no other browsers get this style sheet. So it's perfectly safe in us on any browser.

If you use a version of Plone that is older than 2.1, please check that your visualIEFloatFix matches the above, since this bug has gone through a few iterations before reaching its current form.

What this rule does is to apply a very small height to the element, forcing Internet Explorer into something called "layout mode". The reason for the disappearing text problem is that IE caches the size of elements erroneously when handling floating elements, and setting a very small height forces Internet Explorer to re-calculate the height - thus making the text appear again.

How it affects Plone specifically

I have added the fix to be implicit on several commonly used elements that will never be without height. The full list can be found in ploneIEFixes.css, just do a search for Holly hack.

The fix will never be applied in any browser that is not IE because of Plone's setup of the ploneIEFixes.css file.

Some examples of application

You will experience this bug in your own applications sooner or later. Here's an example of how the bug in the screenshot above (double margins) was fixed in the Ploneboard product:

    <div class="boardConversation">     
      <div class="boardComment visualIEFloatFix" tal:repeat="comment comments">
        <metal:comment metal:use-macro="here/comment_view/macros/comment" />
      </div>
    </div>

The important part here is that we apply the visualIEFloatFix class to the comment container - and the bug magically disappears. Also notice how you apply several classes on the same element - by space-separating them. A surprising number of people don't know that it is possible to apply an arbitrary number of classes to an element.

Final words

As you can see, this is a very hard bug to track down if you don't know the cause, and has cased quite a lot of "WTF!" moments throughout the history of Plone. It is also possible to create layouts that need multiple fixes like this, and it's not always possible to find the logic behind the madness - so at that point you will just have to spray your code with the fix until the problem disappears, and test copiously.

I hope this article has been helpful for you, leave comments below if there are things I have missed or that are unclear.

Alexander Limi, Plone Solutions

by Alexander Limi last modified February 4, 2006 - 14:55 All content is copyright Plone Foundation and the individual contributors.

thanks man

Posted by Benny Bottema at March 23, 2006 - 15:31

I created this account just to express my gratitude for this information. Thanks!

Using multiple class definitions

Posted by Ian F. Hood at April 15, 2006 - 20:09

It is important to note how multiple style classes are applied to the object. They are NOT applied in the order you place them in the class="" statement. They are ALWAYS applied in the order they are found in the .css file(s)

class="one two" will always render exactly the same way as class="two one".

Thanks!

Posted by Sander Spies at April 19, 2006 - 20:41

This indeed caused some WTF's, and I couldn't figure out why things disappeared. Usually when a site works and shows correct in FF and strange things happen to that same site in IE it's bug-hunting time. Although I'm aware of some nasty IE bugs, this one was new for me. Thanks for the article!

min-height is better

Posted by Viveka Weiley at July 11, 2007 - 05:22
Hi! I just fixed this bug on my site a few days ago in the contentpanels imagenews template. Should have trawled the howtos first! However I think my solution has a small improvement - I used min-height: 0.01%; instead of height. This will force IE into layout mode, but doesn't have to be hidden from other browsers as I can't think of a situation where it would have a negative effect.

BTW, will Plone 3 abandon the Holly Hack? IE's conditional comments are saner, with the only negative being IE5/Mac support, which is such a dead and broken browser that I think we really can bury it next to Netscape 4. Anyone who is forced to use IE5/Mac these days would have to turn off CSS to view most of the web anyway.

For any issues with the web site functionality, please file a ticket.

Please consult the policy on plone.org content if you want your content published on this site.

Servers and hosting by