IE7 only: float bug on elements with italic, background properties

Setting font-style:italic in your CSS for elements in the vicinity of a floated element can actually trigger a float bug in Internet Explorer 7.

This is only a problem, so far as I can see, when you’re using backgrounds on the unfloated element(s), because thr background image or colour will overrun your floated element.

Want to try it? The situation is as follows:

  1. Float an element containing either an image or text
  2. Continue with unfloated elements so that under normal circumstances they wrap around the floated element
  3. Give the wrapped text a background property, such as a background colour or image

The code so far:

/* CSS */
.floated {float: right;}
p {background: #fc0;}
...
<!-- HTML -->
<div class="floated"><img src="/images/tmp.jpg" /></div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
<p>Class aptent taciti sociosqu ad litora torquent per conubia nostra per inceptos himenaeos</p>

Up to this point everything’s normal:

No bug

So far so good. Now add font-style:italic; to the rule for p.

Here’s Firefox, with no surprises:

Firefox italic float: no bug

But here’s Internet Explorer 7:

IE italic float bug

The only (il)logical answer seems to be the addition of overflow: auto to the rule with the background.

I was clued in by a slightly different issue with the same fix already discovered long ago. Just to remind you once more, this is IE7 only, folks!

Comments

No responses yet to IE7 only: float bug on elements with italic, background properties

Why not give me your comments?

See also:

CSS floats: container does not stretch to fit floated contents

Nested div float problems

This article was formerly titled “Alternative to the PIE clearfix hack” but has since been rewritten. Getting this problem? Example: Left Left Left Left Right Right Right Right <div style="background: red; padding: 2%; border: 1px solid #000;"> <div style="border: 1px solid #000000; ...

  • Originally published: 18 Jan 2006 in Technical

jQuery .html() returns strange results in IE after other bindings

Internet Explorer: where it belongs?

This article originally addressed jQuery 1.3.1. See below for results in jQuery 1.4 (18 January 2010) When I’m testing work done with jQuery in Internet Explorer, I’m normally a karmic cow. ...

  • Originally published: 17 Feb 2009 in Technical

Solution to nested DIV float problems

Nested floated div breaks wrapper!

This item is now out of date. See the updated version. I recently discovered a CSS hack that has come in very handy indeed since. The problem arises in both Firefox and ...

  • Originally published: 12 Sep 2005 in Technical

More IE woes: the curved corner DIV

In my current efforts to adhere to div-only layouts, it was expected that I would eventually get to a sticky point. I’m not used to hacking CSS, so progress for me ...

  • Originally published: 19 Jul 2005 in Technical

Dreamweaver CS3 crashes and won’t start up again

Dreamweaver CS3 crashes and won't restart

Hey kids, this is definitely one of the weirdest bugs I have ever clapped eyes on. Not for the first time, I was happily authoring CSS and Dreamweaver CS3 crashed. Turns ...

  • Originally published: 1 Feb 2008 in Technical

Who is that guy?

Photo of Mike Padgett

Hello you. I'm Mike Padgett and I work in the technology sector as an Information Designer.

I also enjoy travel, concerts, films and walking.

I'm based in Brussels, Belgium. My current favourite Belgian beer is St Feuillien Brune.

RSS feeds