Guides / Snippet library

HTML email snippet library

Copy-paste components that hold up in Outlook, Gmail and Apple Mail. Each one explains where it works and where it doesn’t.

Quick summary: Nine HTML email building blocks: a VML bulletproof button, a padding button, CSS background images with an Outlook VML fallback, two-column responsive stacking, a responsive image, hidden preheader text, an Outlook head reset, dark mode support and a compliant footer. Outlook for Windows renders with Word’s engine, so most of these use table layout and mso conditional comments.

All snippets

Bulletproof button (VML)

ButtonsOutlook 2007–2021, Gmail, Apple Mail

A rounded button that keeps its shape and click area in Outlook for Windows, using VML there and plain CSS everywhere else.

<!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" href="https://example.com" style="height:44px;v-text-anchor:middle;width:200px;" arcsize="12%" stroke="f" fillcolor="#0b6b5c">
  <w:anchorlock/>
  <center style="color:#ffffff;font-family:Arial,sans-serif;font-size:16px;font-weight:bold;">Read the update</center>
</v:roundrect>
<![endif]-->
<!--[if !mso]><!-->
<a href="https://example.com" style="display:inline-block;background:#0b6b5c;color:#ffffff;font-family:Arial,sans-serif;font-size:16px;font-weight:bold;line-height:44px;text-align:center;text-decoration:none;width:200px;border-radius:5px;">Read the update</a>
<!--<![endif]-->

Set the same width, height, colour and link in both versions. Change arcsize to adjust corner rounding in Outlook.

Padding button (simple)

ButtonsGmail, Apple Mail, Outlook.com; padding is partly ignored in Outlook desktop

A table-cell button with padding on the link. Easy to edit, and corners are square in Outlook for Windows.

<table role="presentation" cellpadding="0" cellspacing="0" border="0">
  <tr>
    <td bgcolor="#0b6b5c" style="border-radius:6px;">
      <a href="https://example.com" style="display:inline-block;padding:12px 24px;font-family:Arial,sans-serif;font-size:16px;font-weight:bold;color:#ffffff;text-decoration:none;border-radius:6px;">Get started</a>
    </td>
  </tr>
</table>

Use this when square corners in Outlook desktop are acceptable.

Background image with VML fallback

LayoutOutlook desktop (VML), Gmail, Apple Mail; falls back to colour when images are blocked

A CSS background image with a solid fallback colour and a VML version for Outlook for Windows.

<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr>
    <td background="https://example.com/bg.jpg" bgcolor="#122033" width="600" height="300" valign="top" style="background:#122033 url(https://example.com/bg.jpg) center/cover no-repeat;">
      <!--[if gte mso 9]>
      <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:600px;height:300px;">
      <v:fill type="frame" src="https://example.com/bg.jpg" color="#122033" />
      <v:textbox inset="0,0,0,0">
      <![endif]-->
      <div style="padding:40px;font-family:Arial,sans-serif;color:#ffffff;">
        <h2 style="margin:0;font-size:28px;">Headline over an image</h2>
      </div>
      <!--[if gte mso 9]></v:textbox></v:rect><![endif]-->
    </td>
  </tr>
</table>

Match the VML width and height to the image. Always keep a background colour that gives the text enough contrast.

Two columns that stack on mobile

LayoutGmail, Apple Mail, Outlook desktop, most mobile apps

A hybrid layout: inline-block columns that stack on small screens without media queries, wrapped in an Outlook-only table.

<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr><td align="center">
    <!--[if mso]><table role="presentation" width="600"><tr><td width="300" valign="top"><![endif]-->
    <div style="display:inline-block;width:100%;max-width:300px;vertical-align:top;">
      <p style="margin:0;padding:12px;font-family:Arial,sans-serif;">Left column</p>
    </div>
    <!--[if mso]></td><td width="300" valign="top"><![endif]-->
    <div style="display:inline-block;width:100%;max-width:300px;vertical-align:top;">
      <p style="margin:0;padding:12px;font-family:Arial,sans-serif;">Right column</p>
    </div>
    <!--[if mso]></td></tr></table><![endif]-->
  </td></tr>
</table>

Widths must add up to the container width (here 300 + 300 = 600).

Hidden preheader text

UtilitiesGmail, Apple Mail, Outlook

Controls the preview text shown next to the subject line in the inbox.

<div style="display:none;font-size:1px;line-height:1px;max-height:0;max-width:0;opacity:0;overflow:hidden;mso-hide:all;">
  Your October update is ready.
  &zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;&zwnj;&nbsp;
</div>

Place it directly after the opening body tag. The trailing entities stop clients pulling in body text after your preheader.

Outlook head essentials

UtilitiesOutlook for Windows

Resets that stop Outlook adding extra spacing and scaling your layout on high-DPI screens.

<!--[if mso]>
<noscript><xml><o:OfficeDocumentSettings><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml></noscript>
<style>table,td,div,p{font-family:Arial,sans-serif!important;}table{border-collapse:collapse;}</style>
<![endif]-->
<style>
  table{mso-table-lspace:0pt;mso-table-rspace:0pt;}
  img{-ms-interpolation-mode:bicubic;border:0;}
</style>

Add the xmlns:v and xmlns:o namespaces to your html tag when using VML: xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office".

Dark mode support

UtilitiesApple Mail, Outlook.com and app, Gmail app (partial)

Tells clients your email supports dark mode and supplies dark colours where they honour prefers-color-scheme.

<meta name="color-scheme" content="light dark">
<meta name="supported-color-schemes" content="light dark">
<style>
  @media (prefers-color-scheme: dark){
    .bg{background-color:#0e1621!important;}
    .tx{color:#e8eef5!important;}
    .logo-light{display:none!important;}
    .logo-dark{display:block!important;}
  }
</style>

Gmail on Android and Outlook desktop may recolour or ignore this. Use transparent PNG logos and avoid pure black or white.

Responsive image

LayoutAll major clients

A full-width image that scales down on small screens and shows alt text if images are blocked.

<img src="https://example.com/banner.jpg" alt="Autumn sale banner" width="600" style="display:block;width:100%;max-width:600px;height:auto;border:0;">

The width attribute matters for Outlook. Host the image at an https address and always write meaningful alt text.

Compliant footer

UtilitiesAll clients

A footer with a visible unsubscribe link, sender address and reason for receiving the email.

<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
  <tr>
    <td align="center" style="padding:24px 20px;font-family:Arial,sans-serif;font-size:12px;line-height:18px;color:#4d5b6c;">
      You are receiving this because you subscribed at example.com.<br>
      <a href="https://example.com/unsubscribe" style="color:#4d5b6c;text-decoration:underline;">Unsubscribe</a> · <a href="https://example.com/preferences" style="color:#4d5b6c;text-decoration:underline;">Manage preferences</a><br>
      Example Co., 123 Main Street, Cleveland, OH 44114, USA
    </td>
  </tr>
</table>

US law (CAN-SPAM) requires a physical address and a working opt-out. Gmail and Yahoo also expect one-click unsubscribe headers for bulk senders.

Need hands-on help with this? I freelance on email platforms, automation logic and migrations.

Ask about template coding

Test your edits in the HTML email code studio. Always send a real test to Outlook desktop, Gmail and Apple Mail before launch.