Email

HTML Email: Why It Is So Hard

Why email layouts break across mail apps, which techniques still work, and how to test a template before it reaches thousands of inboxes.

Key takeaways

  • Mail apps support different subsets of HTML and CSS, and they often remove what they don't trust.
  • Table-based layout and inline styles remain the dependable baseline for broad compatibility.
  • Scripts don't run in email, and forms, video and web fonts are unreliable or blocked.
  • Every message needs a plain-text part, useful alt text and readable contrast in light and dark modes.
  • Test real sends in several apps before mailing a list.

HTML email is hard because there is no single email browser. Each mail app renders your markup with its own engine, strips or rewrites parts of it for safety, and applies its own screen width and color scheme. A design that looks perfect in one inbox can collapse, overlap or turn unreadable in another.

The way through is to build conservatively: a simple single-column layout, styles written directly on elements, text that survives without images, and testing in the apps your readers actually use. This article explains where the trouble comes from and what to do about each part of it.

Many renderers, one message

Web developers target a few browser engines that follow shared standards closely. Email has a long tail of environments: webmail inside a browser, desktop programs, phone apps, and security gateways that rewrite messages along the way. The same provider may behave differently on the web, on iOS and on Android.

Classic Outlook for Windows is the best-known example. Since the 2007 version it has used Microsoft Word's rendering engine to display HTML, which handles much of modern CSS poorly. Newer Outlook applications use web-based rendering, so which one your reader has matters. Other apps have their own quirks, and they change with updates, so treat any compatibility claim as something to verify.

One template, many interpreters
Your HTML message The same bytes sent to everyone Text-only view Shows the plain part Screen reader Reads structure and alt text Security gateway Rewrites links, adds banners Webmail Sanitizes and scopes your CSS Desktop client May use an unusual engine Phone app Narrow screen, may rescale Your HTML message The same bytes sent to everyone Webmail Sanitizes and scopes your CSS Desktop client May use an unusual engine Phone app Narrow screen, may rescale Security gateway Rewrites links, adds banners Screen reader Reads structure and alt text Text-only view Shows the plain part

Why apps strip your code

A mail app displays content from strangers inside an interface that holds your private data. If it allowed arbitrary code, any message could try to read other mail or imitate the app itself. So scripts are disabled, many elements are removed, external stylesheets are commonly ignored, and class names may be rewritten so your styles can't leak into the page around them.

Position properties, overlapping layers and certain selectors are frequently dropped for the same reason. A style block in the head is supported by many apps but not all, and some discard it in particular situations, such as when a message is forwarded or viewed in a non-native account.

Layout that still works

The conservative recipe looks old-fashioned to a web developer.

  • One column, around 600 pixels wide at most, that shrinks on small screens.
  • Nested tables for structure, marked as presentational so screen readers don't announce rows and cells.
  • Inline style attributes for anything that must apply.
  • Padding on table cells rather than margins on divs.
  • Media queries as an improvement, never as the only way the layout works.
<table role="presentation" width="100%" cellpadding="0" cellspacing="0">
  <tr>
    <td align="center" style="padding:24px;">
      <table role="presentation" width="600" style="max-width:600px;">
        <tr>
          <td style="font-family:Arial,sans-serif; font-size:16px; line-height:24px;">
            Your order has shipped.
          </td>
        </tr>
      </table>
    </td>
  </tr>
</table>

Developers often write modern, readable source and run it through a tool that inlines the CSS, or use an email-specific markup language that compiles to table layouts. Either approach saves labor. Neither removes the need to test the output.

Build in layers so failure stays readable
Plain text part The message makes sense with no HTML at all. Basic HTML Headings, paragraphs and links in a single column. Inline styling Fonts, color and spacing on each element. Responsive rules Media queries refine small screens where supported. Extras Dark mode tweaks or animation that nobody depends on. Plain text part The message makes sense with no HTML at all. Basic HTML Headings, paragraphs and links in a single column. Inline styling Fonts, color and spacing on each element. Responsive rules Media queries refine small screens where supported. Extras Dark mode tweaks or animation that nobody depends on.

Images and what happens when they don't load

Some apps block remote images until the reader allows them. Others fetch them through a proxy. If your whole message is one big picture, a blocked image leaves a blank rectangle, and the reader can't tell what you wanted.

Keep key text as real text. Give every meaningful image alt text that conveys its purpose, and set width and height so the layout doesn't jump. Use empty alt text for pure decoration. Background images are especially unreliable in some desktop clients, so never place essential text over one without a solid fallback color.

Embedding images inside the message is possible, but it increases size and can show up as attachments. Hosted images over HTTPS are the usual choice. Remember that they also allow open tracking, with the privacy questions described in tracking pixels in email.

Buttons, fonts and interactive parts

A button in email is usually a styled link, often wrapped in a table cell with a background color so it keeps its shape. Image-only buttons disappear when images are blocked.

Web fonts load in a few apps and not in many others. Choose a fallback stack of common system fonts and check that the layout still holds with them, since a wider fallback can wrap headlines badly.

Video, forms, advanced animation and anything requiring script are unreliable. Link to a web page for those. Animated GIFs play in many apps, but some show only the first frame, so put the important information there.

Dark mode

Many apps offer dark mode, and they handle your colors in different ways: some leave HTML alone, some swap light backgrounds for dark ones, some invert more aggressively. A logo with dark lettering on a transparent background can vanish. Black text on an assumed white background can become unreadable if only one of the two changes.

Set text and background colors together. Give logos an outline or a light backing. Where supported, you can supply dark-specific styles, but treat them as a bonus. Check contrast in both modes; color contrast and readability explains the ratios.

Size, clipping and weight

Heavy markup causes problems beyond load time. Gmail truncates very large HTML bodies, at roughly 100 kilobytes, and shows a link to view the rest, which can hide your footer and unsubscribe link. Editors that generate deeply nested, repetitive code get there faster than you'd think. Images don't count toward that HTML size, but they still slow readers on mobile connections.

Strip comments and unused styles, avoid pasting from word processors, and measure the final HTML after any tracking links are added.

The links in your message may not stay as you wrote them. Sending platforms often replace each address with a tracking address that records the click and then redirects. Corporate security systems may rewrite links again so they can scan the destination at click time. Both lengthen addresses, add weight to the HTML and can confuse readers who inspect them.

Keep a few habits. Use a tracking domain that belongs to you where your platform allows it, so the address matches the sender. Avoid showing one web address as link text while pointing somewhere else, because that is exactly what phishing does and filters notice. Test one-time links, such as sign-in or confirmation links, against automated scanners: if opening a link once uses it up, a scanner may consume it before the person ever clicks. A landing page with a button that completes the action avoids that.

Personalization and merge fields

Templates usually fill in names, amounts and dates at send time. This is where embarrassing errors happen.

  • Provide a fallback for every field, so a missing first name doesn't produce "Hi ,".
  • Escape user-supplied values so that stray characters can't break your markup.
  • Test very long names, names with apostrophes and non-Latin scripts.
  • Format dates and currency for the reader, and include a time zone where timing matters.
  • Check empty states: an order with no items or a report with no data.

Also check the preheader, the short preview text shown next to the subject in many inboxes. If you don't set one, the app shows whatever text comes first, which might be "View this email in your browser" or an image description.

A realistic definition of done

Perfect, identical rendering everywhere is not an achievable goal. Aim for a message that is fully readable and usable in every app your audience uses, and attractive in the common ones. A slightly different corner radius or font in one client is fine. A hidden button, overlapping text or an invisible logo is a bug.

Once you have a template that meets that bar, reuse it. Resist redesigning each campaign from scratch, since every new layout reopens every compatibility question. Version your templates like other code, note which clients you tested and when, and retest after you change structure or after readers report something odd.

The MIME structure underneath

A proper HTML message carries two versions of its content in a container called multipart/alternative: a text/plain part and a text/html part. The reader's app picks the one it prefers. MIME (Multipurpose Internet Mail Extensions) is the family of standards that makes this packaging work.

Write the plain part deliberately. An automatically generated one full of long tracking addresses is unpleasant to read and can look careless to filters. Also encode the message in UTF-8 so accented letters and symbols survive; character encoding explained covers why.

Accessibility

Email is read with screen readers, zoom and keyboard-only setups.

  • Set the language on the document where you can.
  • Use real headings and short paragraphs.
  • Write link text that says where it goes, not "click here".
  • Keep body text at a comfortable size, around 16 pixels, with generous line height.
  • Don't convey meaning by color alone.

Web accessibility explained applies almost entirely to email too.

A testing routine

Check a template before the real send
1 Validate content Proofread, check links and merge fields with odd test data. 2 Send to real accounts Cover the main webmail, desktop and phone apps you serve. 3 Try bad conditions Images off, dark mode, large text and a narrow screen. 4 Forward and reply See what survives when the message is passed on. 5 Check headers Confirm authentication passes and unsubscribe works. Validate content Proofread, check links and merge fields with odd test data. 1 Send to real accounts Cover the main webmail, desktop and phone apps you serve. 2 Try bad conditions Images off, dark mode, large text and a narrow screen. 3 Forward and reply See what survives when the message is passed on. 4 Check headers Confirm authentication passes and unsubscribe works. 5

Rendering preview services can show many clients at once and are useful for teams that send often. A handful of free test accounts covers a lot for everyone else. Start with the apps your audience uses most.

Common questions

Should I just send plain text?

For personal notes, support replies and many product notices, plain or very light HTML works beautifully and rarely breaks. Choose rich design when it helps the reader, such as showing products.

Can I use flexbox or grid?

Some apps support them and others don't. If you use them, make sure the content stacks sensibly when they are ignored.

Why does my message look different after forwarding?

The forwarding app rewrites your HTML into its own editor format, often dropping style blocks. Inline styles survive better, though nothing is guaranteed.

Written for 4Internet with AI writing tools and not reviewed line by line by a person. Check anything you rely on with the maker, provider or standard concerned. Report an error.

Keep reading

All 45 articles in Email →

Latest news on this topic