css padding is not working in outlook

2019-01-10 20:25发布

I have following html in email template.

I am getting different view in MS Outlook and in gmail for the same.

<tr>
    <td bgcolor="#7d9aaa" style="color: #fff; font-size:15px; font-family:Arial, Helvetica, sans-serif; padding: 12px 2px 12px 0px; ">
    <span style="font-weight: bold;padding-right:150px;padding-left: 35px;">Order Confirmation </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <span style="font-weight: bold;width:400px;"> Your Confirmation number is {{var order.increment_id}} </span></td>
</tr>

In gmail

In outlook

How to fix this?

12条回答
劫难
2楼-- · 2019-01-10 20:44

I had the same problem and ended up actually using border instead of padding.

查看更多
Rolldiameter
3楼-- · 2019-01-10 20:51

I changed to following and it worked for me

<tr>
    <td bgcolor="#7d9aaa" style="color: #fff; font-size:15px; font-family:Arial, Helvetica, sans-serif; padding: 12px 2px 12px 0px; ">                              
        <table style="width:620px; border:0; text-align:center;" cellpadding="0" cellspacing="0">               
            <td style="font-weight: bold;padding-right:160px;color: #fff">Order Confirmation </td>                    
            <td style="font-weight: bold;width:260px;color: #fff">Your Confirmation number is {{var order.increment_id}} </td>              
        </table>                    
    </td>
</tr>

Update based on Bsalex request what has actually changed. I replaced span tag

<span style="font-weight: bold;padding-right:150px;padding-left: 35px;">Order Confirmation </span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<span style="font-weight: bold;width:400px;"> Your Confirmation number is {{var order.increment_id}} </span>

with table and td tags as following

   <table style="width:620px; border:0; text-align:center;" cellpadding="0" cellspacing="0"> 
      <td style="font-weight: bold;padding-right:160px;color: #fff">Order Confirmation </td>
      <td style="font-weight: bold;width:260px;color: #fff">Your Confirmation number is {{var order.increment_id}} </td>
   </table>
查看更多
Melony?
4楼-- · 2019-01-10 20:51

As monners says some email clients are horrible handling paddings. You can use empty rows and cells as he suggests (with the precaution to set the line-height to 1, if not the line height of the td may be higher than the padding).

I have particulary found another solution, using borders the same colour of the background. I've tested this solution positively in gmail (and gmail for business), yahoo mail, outlook web, outlook desktop, thunderbird and works correctly.

Example:

<table>
    <tr>
        <!--use border same color of bg-->
        <td style="border: solid 10px #ffffff">
           <!--Content goes here-->
        </td>
    </tr>
</table>

<!--Same result with padding-->
<table>
    <tr>
        <!--use paddings-->
        <td style="padding: 10px 10px 10px 10px">
           <!--Content goes here-->
        </td>
    </tr>
</table>

<!--using empty td/tr-->
<table>
    <tr>
        <td height="10" style="height: 10px; line-height: 1px"></td>
    </tr>
    <tr>
        <td width="10" style="width: 10px; line-height: 1px"></td>
        <td>
           <!--Content goes here-->
        </td>
        <td width="10" style="width: 10px; line-height: 1px"></td>
    </tr>
    <tr>
        <td height="10" style="height: 10px; line-height: 1px"></td>
    </tr>
</table>

In addition, here is an excelent guide to make responsive newsletters WITHOUT mediaqueries, I've been using this guide for long now and it's excellent: https://webdesign.tutsplus.com/tutorials/creating-a-future-proof-responsive-email-without-media-queries--cms-23919

And you can test all your email in: https://putsmail.com/

And always remember to make your css inline, I use: https://inliner.cm/

Finally, if you have doubts about css support you can go here: https://templates.mailchimp.com/resources/email-client-css-support/

or here: https://www.campaignmonitor.com/css/

查看更多
Bombasti
5楼-- · 2019-01-10 20:52

Just use
<Table cellpadding="10" ..> ... </Table>
Don't use px.Works in MS-Outlook.

查看更多
走好不送
6楼-- · 2019-01-10 20:55

Padding will not work in Outlook. Instead of adding blank Image, you can simply use multiple spaces(& nbsp;) before elements/texts for padding left For padding top or bottom, you can add a div containing just spaces(& nbsp;) alone. This will work!!!

查看更多
兄弟一词,经得起流年.
7楼-- · 2019-01-10 20:56

Unfortunately, when it comes to EDMs, Outlook is your worst enemy. Some versions don't respect padding when a cell's content dictates the cell dimensions.

The approach that'll give you the most consistent result across mail clients is to use empty table cells as padding (I know, the horror), but remember to fill those tables with a blank image of the desired dimensions because, you guessed it, some versions of Outlook don't respect height/width declarations of empty cells.

Aren't EDMs fun? (No. They are not.)

查看更多
登录 后发表回答