docs/features/email/email-html-best-practices.md
Email design and development require a different approach than traditional web development. This guide outlines best practices for ensuring your HTML emails render correctly across all major email clients.
<section>, <article>, and <aside> aren't supported in all email clients. ) - This prevents rendering issues in clients that expect XHTML-style syntax.align and valign attributes instead of CSS equivalents - These HTML attributes have better support than CSS positioning in email clients.<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td align="center" valign="top">
<!-- Content here -->
</td>
</tr>
</table>
<style> tags or ignore them entirely.margin-top instead of margin) - Some email clients only recognize individual properties, not shorthand.position, float, clear) - These are poorly supported and can cause layout issues.<p style="font-family: Arial, sans-serif; font-size: 16px; line-height: 24px; color: #333333;">
Your content here
</p>
<style type="text/css">Well-supported:
font-family, font-size, color - Basic text styling has consistent support across email clients.text-align, line-height - Text alignment and spacing properties work reliably in most clients.width, height, padding, margin (with caution) - Basic box model properties work when used conservatively. Margin doesn't work properly in Outlook.border, background-color - These visual properties have good support in most email clients.Poorly supported or inconsistent:
position, display) - These can cause emails to render differently or break layouts in some clients.<table border="0" cellpadding="0" cellspacing="0" width="600">
<tr>
<td width="300" valign="top">
<!-- Column 1 content -->
</td>
<td width="300" valign="top">
<!-- Column 2 content -->
</td>
</tr>
</table>
<!--[if mso]>
<table border="0" cellpadding="0" cellspacing="0" width="600">
<tr><td width="300" valign="top"><![endif]-->
<div style="display: inline-block; width: 300px; vertical-align: top;">
<!-- Column 1 content -->
</div>
<!--[if mso]></td><td width="300" valign="top"><![endif]-->
<div style="display: inline-block; width: 300px; vertical-align: top;">
<!-- Column 2 content -->
</div>
<!--[if mso]></td></tr></table><![endif]-->
Limited but important support:
<style type="text/css">
@media screen and (max-width: 480px) {
.mobile-full-width {
width: 100% !important;
height: auto !important;
}
.mobile-font {
font-size: 16px !important;
}
}
</style>
Uses max-width and MSO conditionals to work across clients with or without media query support:
<!--[if mso]>
<table width="600" cellpadding="0" cellspacing="0" border="0"><tr><td>
<![endif]-->
<div style="width:100%; max-width:600px; margin:0 auto;">
<!-- Content -->
</div>
<!--[if mso]>
</td></tr></table>
<![endif]-->
Always use a font stack with widely supported fonts:
font-family: Arial, Helvetica, sans-serif;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-family: 'Times New Roman', Times, serif;
font-family: Verdana, Geneva, sans-serif;
font-family: Georgia, Times, 'Times New Roman', serif;
font-family: 'Courier New', Courier, monospace;
<style>
@import url('https://fonts.googleapis.com/css2?family=Open+Sans&display=swap');
</style>
<p style="font-family: 'Open Sans', Arial, sans-serif;">Your text</p>
alt attribute - This provides text alternatives when images are blocked and improves accessibility.Limited support; always provide a fallback bgcolor:
<table background="https://example.com/bg.jpg" bgcolor="#f7f7f7" width="600" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
Content
</td>
</tr>
</table>
<!--[if mso]>
Outlook-specific content here
<![endif]-->
p, h1, h2, etc.) - This improves screen reader interpretation and overall accessibility.role="presentation" to layout tables - This tells screen readers the table is for layout only, not data presentation.aria-hidden="true" for decorative elements - This prevents screen readers from announcing purely visual elements.<table role="presentation" border="0" cellpadding="0" cellspacing="0">