IE6 image plus div problem

From Visual Basic to GNU C, this is the place to talk programming.

Moderators: SecretSquirrel, just brew it!

IE6 image plus div problem

Postposted on Fri Apr 03, 2009 6:00 am

The problem I'm having with IE6 and images is with putting an image of the same dimensions of the div inside that div. The image stretches the div's width past what it should be. FF3 renders it correctly. Below is the html+css I'm using and 2 screenshots comparing the 2 behaviors.

Code: Select all
<div id="nav">
   <img src="img/nav.jpg">

Code: Select all
   border:1px solid #000;
   margin:50px auto 0px auto;

The font-size:1px; is in there to fix the -3px IE6 margin error.

Firefox 3 rendering:

IE6 rendering:

So, does anyone have an idea how to fix this? It's for a computer repair site (granted, the site will probably be redesigned quickly) and IE6 is most likely a mainstay of computers that need repair :P


I compared the widths of the frame below (which is of the same width) and it turns out that IE6 is rendering a div with width of 700px as 698, meaning that "stretching" of the div above is actually correct. I've also noticed that when I removed the border, it would render to the full 700px. I guess IE6 sees the border as 700px including the border...

Anyone have a fix for this?


Ok, found out the problem. I had

Code: Select all
<?xml version="1.0" encoding="UTF-8"?>

At the beginning which triggers IE6 to render CSS boxes as IE5. Or something like that. Removing the line fixes the behavior. ... 03714.html

Damn you IE6!
Grand Gerbil Poohbah
Posts: 3280
Joined: Wed Jul 19, 2006 1:51 am
Location: Minnesota

Return to Developer's Den

Who is online

Users browsing this forum: No registered users and 1 guest