views:

662

answers:

3

I have the following simple table to reproduce the issue:

<TABLE>
  <TR>
    <TD style="border: black solid 1px; width:24px; height:68px; margin:0px; padding:0px" >
    <IMG 
      style="width: 24px; height: 68px; margin:0px; padding:0px; border:none" 
      src="Image24x68.png"> 
    </TD>
  </TR>
</TABLE>

The image is actually 24x86 pixels large. The border is just to mark the cell's boundaries. There is no css file assigned to the document.

I want the cell to be exactly as large as the image.

The problem is: the table cell gets always rendered a few pixels too high in any IE version (6, 7, 8) while it works fine in Firefox and other browsers.

Is there any solution / workaround for this? Thanks a lot

+3  A: 

Looks like this: http://www.evilfish.co.uk/2007/07/31/ie-white-space-after-image-bug/

Remove all whitespace between the image and the closing td tag. In front of the image it doesn't seem to matter.

andre-r
Wow. Terrible. This really solves the problem. But it's hard to make sure that there is not white space after the image, because the whole stuff is created by some (also very ugly) php code...
Stefan Steinegger
+1 on Mark B's solution
andre-r
+2  A: 

You can set the images to display as block elements and this should remove the space.

<IMG style="display: block; width: 24px; height: 68px; margin:0px; padding:0px; border:none" src="Image24x68.png">
Mark B
This seems to be a nice solution, because i could put this into the css file.
Stefan Steinegger
Yes, putting it into the main CSS stylesheet would certainly be best - I just added it inline to illustrate the point.
Mark B
A: 

Try the following:

<table>
  <tr>
    <td style="border: 1px solid black; font-size: 1pt;">
    <img style="width: 24px; height: 68px; margin: 0;
       padding: 0; border: 0" src="Image24x68.png" /> 
    </td>
  </tr>
</table>

(PS Use lower case for HTML tags.)

Anax
The upper case HTML tags where actually created by IE when I stored the page to a local folder. It rewrites all tags to uppercase ...
Stefan Steinegger