Inline Wrap Bug of Internet Explorer
24. April 2006 von Michael | Webmaster/CMS/Blog
Hinweis für deutschsprachige Leser: Dieser Artikel ist ausnahmsweise in Englisch aufgrund der Relevanz und dem Querverweis vom WordPress-Plugin Link Indication.
Once in a while it is necessary to add little inline images next to words or links when designing a website. It’s recommended to use CSS for this purpose, in the following an example that adds an image to the right side of a link.
CSS:
a.liexternal {
background: url(images/icon.gif) no-repeat right;
padding-right: 10px;
}
HTML and output:

Problem
That is working well with all browsers except Internet Explorer: If a word-wrap is needed, the Internet Explorer fails. It displays only a part of the image, but not at the correct position. See the following examples.
Firefox, Opera:

Internet Explorer 5.5, 6, 7:

First solution
The blue moped bloghas evaluated this issue and recommends the following solution: Using display: inline-block in the CSS:
a.liexternal {
background: url(images/icon.gif) no-repeat right;
padding-right: 10px;
display: inline-block;
}
However, using display: inline-block causes the follwing issues:
- All current CSS validators are checking CSS according to CSS2, but
display: inline-blockis not valid acc. to CSS2, therefore an error occurs. Butdisplay: inline-blockis correct according to CSS2.1: When you use the validator at jigsaw.w3.org, you can select “CSS2.1″ and finally your CSS will be valid. - The Opera browser changes the height of elements and moves them a few pixels to the top:
Final solution
display: inline-block should be applied only if visitors are using the Internet Explorer. So I recommend creating an additional CSS file where you apply display: inline-block to the according elements:
a.liexternal {
display: inline-block;
}
Apply this additional CSS file by using conditional comments in the head of the HTML:
<!--[if gte IE 5.5]>
<style type="text/css" media="screen">
@import url( styles/style_ie.css );
</style>
<![endif]-->



Was ist ein Trackback?
4 Trackbacks/Pings:
1
blue moped blog » Blog Archive » The IE inline-wrap bug
Pingback vom 26. April 2006, 0:00
Ein weiteres Problem wird durch Opera generiert. Michael Wöhrer hat in seinem Blog darauf hingwiesen, dass display: inline-block in diesem Browser dazu führt, dass das Element ei…
2
Het up about movie » Blog Archive
Pingback vom 28. Februar 2007, 15:47
Question: In the Internet Explorer, sometimes the icon is not displayed after the link. Why? Answer: This is an IE bug, and you can see this issue also e.g. on Wikipedia. Here you …
3
Neues Plugin: Link Indication - Duerrbi & Michi
Pingback vom 30. Mai 2007, 13:48
eines Bugs im IE (ab 5.5) muss lediglich noch eine Anpassung in der HEADER.PHP durchgeführt
4
Tigions Blog » Blog Archiv » Link indication - Der Kompromiss des Linkbildes
Pingback vom 28. Juni 2007, 14:22
für die fehlerhafte Darstellung ist der Zeilenumbruch innerhalb eines Links. Ein mögliche Lösung wäre die zusätzlichen Angabe display:
8 Comments:
1
Cybaer
12. Juni 2006, 15:29
Hi,
yes, this is the solution! Great idea! :)
But IE 5.5 is the first IE with “inline-block”! So this workaround should be loaded with IE 5.5+ and not with older IE’s. Therefore the Conditional Comment should be:
<!--[if gte IE 5.5]>Regards, Cybaer
2
Michael (Author)
13. Juni 2006, 21:23
Thanks for your info, Cybaer, I have corrected it.
3
Steffen
22. Oktober 2006, 11:23
I created another possible solution. Which ist CSS valid in all cases and works without conditional comments.
Just use this CSS Definition:
You can use the position attribute twice. It Works ;)
4
Michael (Author)
28. Dezember 2006, 14:05
Steffen, sorry, I’ve missed your comment. Just adding “center” as the second argument of background-position will not solve the IE problem when using a right aligned image.
5
Dicontas
16. Januar 2007, 16:32
this fix worked perfectly on WordPress with my new CSS file for IE
6
Stephan
12. Februar 2007, 7:23
Thanks for the info.
I played a little around. The problem is the hasLayout property from the Internet Explorer. Instead of
a.liexternal { display: inline-block; }you also can use
a.liexternal { zoom: 1; }to trigger the hasLayout property.
I use “height:1%” to solve the Inline Wrap Bug in IE5.0. That works also for IE5.5 up to IE6.
* html a.liexternal { height:1%; }7
theUg
16. Februar 2007, 7:46
There’s similar bug in Opera. If you use these styles within the paragraph, that is justified, some of the images show up out of place, like as if it shifts around, not sticking to the right edge of the container.
If text is left or right-aligned then it works fine.
8
Abu
9. Juli 2007, 5:52
Does anyone know how reliable suggestion #6 is?
Die Kommentarmöglichkeit ist derzeit für diesen Artikel ausgeschaltet.