Remove spacing between table cells and rows

前端 未结 11 1741
我寻月下人不归
我寻月下人不归 2021-02-01 12:49

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) removin

相关标签:
11条回答
  • 2021-02-01 13:11

    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">
    
    0 讨论(0)
  • 2021-02-01 13:13

    I had a similar problem and I solved it by (inline)styling the td element as follows :

    <td style="display: block;"> 
    

    This will work although its not the best practice. In my case I was working on a old template that had been styled using HTML tables.

    0 讨论(0)
  • 2021-02-01 13:17

    Nothing has worked. The solution for the issue is.

    <style>
    table td {
        padding: 0;
    }
    </style>
    
    0 讨论(0)
  • 2021-02-01 13:17

    If the caption box is gray then you can try wrapping the image and the caption in a div with the same background color of gray---so a "div" tag before the "tr" tag...This will mask the gap because instead of being white, it will be gray and look like part of the gray caption.

    0 讨论(0)
  • 2021-02-01 13:21

    You have cellspacing="0" twice, try replacing the second one with cellpadding="0" instead.

    0 讨论(0)
  • 2021-02-01 13:24

    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.

    0 讨论(0)
提交回复
热议问题