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

— What do you get if you cross a float and an italic in Internet Explorer?…”

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?

You can use these tags in your comment:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

See also:

CSS floats: container does not stretch to fit floated contents

Nested div float problems

Here’s a quick resolution to an almost ungooglable problem. ...

  • Originally published: 18 Jan 2006 in Technical

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

Internet Explorer: where it belongs?

Sometimes we’re stuck with junk attributes in jQuery.html() for Internet Explorer. ...

  • Originally published: 17 Feb 2009 in Technical

Solution to nested DIV float problems

Nested floated div breaks wrapper!

A CSS hack for nested divs that break out of their container. ...

  • Originally published: 12 Sep 2005 in Technical

More IE woes: the curved corner DIV

IE in freefall

Rendering CSS rounded corners is still surprisingly difficult thanks to inconsistent applied browser standards. ...

  • Originally published: 19 Jul 2005 in Technical

Dreamweaver CS3 crashes and won’t start up again

Dreamweaver CS3 crashes and won't restart

The world famous 8,192kb bug that crashed a million Dreamweavers. Probably. ...

  • Originally published: 1 Feb 2008 in Technical

Who you gonna call?

Photo

Hello you, I'm Mike Padgett. I'm not the Princeton curator, the US senatorial candidate, the Kentuckian pastor or the journalist from Arizona. In fact, I work as a consultant in User Experience and Information Design.

I also enjoy travel, concerts, films and walking.

I'm originally from Yorkshire, England but nowadays I live in Brussels, Belgium. My current favourite Belgian beer is Ellezelloise Hercule.

RSS feeds