Remove spacing between table cells and rows
Solution 1
It looks like the DOCTYPE is causing the image to display as an inline element. If I add display: block
to the image, problem solved.
Solution 2
Add border-collapse: collapse
into the style
attribute value of the inner table
element. You could alternatively add the attribute cellspacing=0
there, but then you would have a double border between the cells.
I.e.:
<table class="main-story-image" style="float: left; width: 180px; margin: 0 25px 25px 25px; border-collapse: collapse">
Solution 3
I had a similar problem. This helps me across main email clients. Add:
- attributes
cellpadding="0"
,cellspacing="0"
andborder="0"
to tables - style
border-collapse: collapse;
to tables - styles
padding: 0; margin: 0;
to each element - and styles
font-size: 0px; line-height: 0px;
to each element which is empty
Solution 4
You have cellspacing="0"
twice, try replacing the second one with cellpadding="0"
instead.
Solution 5
If you see table class it has border-spacing: 2px; You could override table class in your css and set its border-spacing: 0px!important in table; I did it like
table {
border-collapse: separate;
white-space: normal;
line-height: normal;
font-weight: normal;
font-size: medium;
font-style: normal;
color: -internal-quirk-inherit;
text-align: start;
border-spacing: 0px!important;
font-variant: normal; }
It saved my day.Hope it would be of help. Thanks.
Joe Mornin
Updated on April 15, 2020Comments
-
Joe Mornin about 4 years
I'm designing an HTML email template, which forces me to use tables. In the code below, I'm having trouble (1) removing the spacing below the placeholder image and (2) removing the space between the image and the caption. Here's a screenshot of how it looks in Chrome 15 on OS X 10.6.8.:
<!DOCTYPE HTML> <html> <head> <title>Email Template</title> <meta http-equiv="content-type" content="text/html;charset=utf-8" /> </head> <body> <table style="border: 1px solid #b50b32; margin: 30px auto; width: 600px; padding: 0; border-spacing: none;" cellspacing="0" cellpadding="0"> <tr> <td id="main" style="background-color: #f2f2f2;"> <h2 style="color: #b50b32; font-family: 'Lucida Grande', Arial, sans-serif; font-size: 22px; font-weight: normal; padding: 15px; margin: 25px 0; background-color: #fff;">Major headline goes here</h2> <table class="main-story-image" style="float: left; width: 180px; margin: 0 25px 25px 25px;"> <tr><td style="padding: 0; border: 1px solid red;"><img src="placeholder.jpg" width="180" height="130" style="border: none; margin: 0; padding: 0;" alt="Placeholder" /></td></tr> <tr><td style="padding: 0; border: 1px solid red;"><p class="image-caption" style="background-color: #bebebe; color: #333; font-family: 'Lucida Grande', Arial, sans-serif; margin: 0; padding: 5px;">Caption.</p></td></tr> </table><!--/.main-story-image--> <p style="margin: 0 50px 25px 25px;">Lorem ipsum dolor sit amet.</p> <p><a href="">Click here to read more </a></p> <div style="clear: both;"></div> </td><!--/#main--> </tr> </table> </body> </html>
The red borders are there only to show the outlines of the cells. I don't want them there in the final version.