When it comes to coding HTML emails, the golden rule is to embrace the retro vibes of the 90s. Think table layouts all the way!
Encase everything in a Table width
border="0" cellspacing="0" cellpadding="0"
While some mail clients support CSS, others completely filter it out. It's safest to stick with inline-styles, utilizing <font>
tags for text formatting and the old-school bgcolor
attribute. When it comes to padding and margins, opt for empty table cells with transparent gifs rather than CSS properties. Ensure height is applied to not just the img
tag, but also the td
and even the tr
tag.
Gmail has made strides by allowing media queries for responsiveness, but widespread adoption is still pending.
In light of inconsistent media query support and the prevalence of mobile devices, taking a "mobile-first" approach and using media queries for larger screens can be beneficial. For Outlook users, conditional comments can help achieve similar results:
<!--[if mso]>
<style>/* style block will only be used in MSO */</style>
<![endif]-->
You can target specific versions of Outlook, like Windows 10 Mail app being mso 16
, using the likes of lte/gte/gt/lt
. Additionally, MSO-specific styles such as mso-line-height-alt:0;
can aid in controlling line heights and removing unwanted spaces.
Avoid using float for column layouts; instead, use align="left"
on each table representing a column (excluding the last table in a row to prevent layout issues). Thunderbird specifically struggles with floating tables.
Building an email template entails a cycle of creation, testing across various clients, troubleshooting, delving into client-specific quirks, experimenting with solutions, and repeating the testing process.