I am currently redesigning some HTML email templates, which is something I haven't done for a couple of years in this much depth.
I've made my template in an HTML file which I'm testing locally in the browser, and it all looks fine.
- I'm using tables for layout
- The only other tags I'm using are
<p>
<a>
and<img>
- The CSS is in a
<style>
tag after the opening<body>
tag for now but I am converting it to inline styles before sending, using MailChimp's CSS Inliner Tool. I just put it in a style tag for you to see the CSS easier here. It makes no difference in a lot of clients anyway, for testing purposes.
Now that I'm sending test emails from my PHP application, I'm trying to get them to come through to the email client(s) looking the same as my mockup.
The main thing I notice is that the margin/padding styles seem to be either ignored (e.g. Outlook 2007) or extra padding/margin is added on things like <td>
which makes everything way more padded than I told it to be (e.g. Hotmail).
Example Source
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<body>
<style type="text/css">
td {font-family:Arial, Helvetica, sans-serif; font-size:13px; color:#444;}
a {color:#056DA5;}
p {margin:0; padding:6px 0 6px 0;}
.tel {font-weight:bold; color:#056DA5;}
#wrapper {padding:10px;}
#signoff {padding:18px 0;}
#signoff #questions {padding-bottom:18px;}
#signature {padding-top:20px; border-top:1px solid #EEE;}
#signature td {font-size:12px; color:#777;}
#signature #logo {padding-bottom:12px;}
#signature #contact p {padding:3px 0 3px 0;}
#signature #contact a {text-decoration:none; font-size:13px; font-weight:bold; color:#C00;}
#signature #contact .tel {padding-top:6px; color:#777;}
#signature #social {padding:20px 0 20px 0;}
#signature #social a {margin-right:8px;}
#signature #address {font-size:11px; color:#999;}
</style>
<table id="wrapper" width="100%" bgcolor="#FFFFFF">
<tr>
<td>
<table>
<!-- ROW 1 -->
<tr>
<td>[CONTENT]</td>
</tr>
<!-- ROW 2 -->
<tr>
<td id="signoff">
<p id="questions">If you have any questions, email us at <a href="mailto:support@example.com">support@example.com</a> or call <span class="tel">01234567890</span>.</p>
<p>Thanks,</p>
<p>Company</p>
</td>
</tr>
<!-- ROW 3 -->
<tr>
<td id="signature">
<table cellpadding="0" cellspacing="0">
<tr>
<td id="logo" colspan="3">
<img src="http://www.example.com/images/email/logo.gif" alt="Company" />
</td>
</tr>
<tr>
<td id="contact">
<p><a href="http://www.example.com">www.example.com</a></p>
<p><a href="mailto:support@example.com">support@example.com</a></p>
<p class="tel">01234567890</p>
</td>
</tr>
<tr>
<td id="social">
<a href="https://www.facebook.com/"><img src="http://www.example.com/images/email/facebook.gif" alt="Facebook" /></a>
<a href="https://twitter.com/"><img src="http://www.example.com/images/email/twitter.gif" alt="Twitter" /></a>
</td>
</tr>
<tr>
<td id="address">Company, address, city, post code</td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
Try viewing the HTML in your browser, and then try sending as an email to see what I mean.
What am I doing wrong and how can I make the email come through with the intended CSS?