Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mystery padding in table cells with image

Tags:

I hate to admit this: I'm building a complicated, but gmail-friendly HTML email blast (inline styling). Anyway, it's a game of tables and split images, and I've seemed to have forgotten all my 1995 table mojo.

http://www.highgatecross.com/development/tables/

<table border="0" cellpadding="0" cellspacing="0">     <tr>         <td><img src="skyline.jpg" alt=""></td>         <td><img src="skyline-02.jpg" alt=""></td>         <td><img src="skyline-03.jpg" alt=""></td>     </tr>     <tr>         <td colspan="3"><img src="skyline-04.jpg" alt=""></td>      </tr> </table> 

I have a mystery 4-pixel "padding" below each images (the DOM panel in Firebug shows a cell "clientHeight" 4 pixels greater than my images).

I have tried every combination of deprecated HTML styling (heights, etc.) and CSS and no joy.

So, simply, how do I rid the 4 pixels and close the gap between rows?

like image 746
breadwild Avatar asked Oct 27 '10 02:10

breadwild


People also ask

How do I remove the space under an image in a table cell?

In IE7, if you have a table cell with an image displayed in it, you may have noticed a small space underneath the image in the table cell. This space occurs in IE7 but not Firefox. This space can be removed by setting the style of the image to be 'block' rather than 'inline'. This is demonstrated in style-test.

How do you add padding between cells in a table?

Cell padding is the space between cell borders and the content within a cell. To set cell padding in HTML, use the style attribute. The style attribute specifies an inline style for an element. The attribute is used with the HTML <table> tag, with the CSS property padding.

What is cell padding in a table?

Cell padding is the space between the cell edges and the cell content. By default the padding is set to 0.

What is cell padding attribute?

The cellpadding attribute specifies the space, in pixels, between the cell wall and the cell content. Note: Do not confuse this with the cellspacing attribute, which specifies the space between cells.


2 Answers

Just use style="display: block" on the image.

Problem solved.

like image 160
Marko Avatar answered Oct 18 '22 12:10

Marko


I should have checked StackOverflow first!

Either:

<img src="some.jpg" style="display: block" /> 

or

<img src="some.jpg" style="vertical-align: bottom" /> 

will eliminate the 4 pixels under the image in a table cell.

like image 33
breadwild Avatar answered Oct 18 '22 13:10

breadwild