Skip to content
Back to blogGuide

HTML email best practices for developers

6 min read
Diagram of HTML email practices: tables, inline CSS, and a plain-text alternative

Email HTML is a constrained runtime. The useful practices are boring: tables for layout, inline CSS, absolute image sizes, a plain-text part, and a design that still works when half the CSS disappears.

This is a developer-focused checklist. For QA, see how to test HTML emails and the email client test-plan tool. For client bugs, see rendering issues and Outlook rendering fixes. Tools: preview, compatibility checker, HTML fix assistant, inliner, HTML to plain text.

Direct answer

  • Design to 600px content width with a fluid outer table.
  • Use tables, not flexbox or grid, for structure.
  • Inline critical CSS. Keep a small <style> block only for enhancements (media queries, dark mode).
  • Set width and height on images. Always include alt.
  • Make the default layout readable without media queries.
  • Ship multipart/alternative with a real text part.
  • Keep HTML lean enough to avoid Gmail clipping.
  • Test Outlook Desktop, Gmail, and Apple Mail—not only Chrome.

Think in documents, not apps

You are not shipping React to the inbox. Clients will:

  • Strip <script> (good)
  • Rewrite links
  • Block images
  • Drop or invert colors
  • Ignore half of CSS

So avoid depending on:

  • JavaScript
  • Web fonts as the only typeface
  • CSS grid / flex as the column system
  • Background images without a fallback color and live text
  • Forms that post from the email (use a link to a page)
  • Video tags (use a linked poster image)

The HTML to string converter is for putting markup in code. It is not a sending format.

Tables that do not rot

Patterns that hold up:

  • Outer table 100% wide, background on body/outer
  • Inner table 600px (or max-width with a width attribute)
  • Rows as sections: hero, body, button, footer
  • Nested tables for two columns, with a stacked fallback

Use role="presentation" on layout tables so screen readers do not announce “table with 12 rows.” Put real lists and headings in the content cells.

Cell padding is more reliable than margin on <p> in Outlook. Reset with inline margin:0 on paragraphs if spacing doubles.

CSS: inline first, enhance second

Inline font-family, font-size, line-height, color, background, padding on the elements that need them. The inliner exists for this.

Leave in a <style> block:

  • @media to stack columns in clients that honor it
  • :hover on buttons in Apple Mail
  • Dark-mode @media (prefers-color-scheme: dark) for clients that honor it

Do not put the only copy of a color in the head. Gmail may keep some classes; Outlook Desktop will not.

Shorthand CSS is messy in Outlook (font: especially). Prefer longhand.

Images and buttons

Images:

  • Host on HTTPS
  • Compress
  • Exact pixel dimensions
  • Alt that states the claim if the image is the headline
  • No 1200px retina dump scaled down in HTML without need

Buttons:

  • A table with padding and a link, or a padded <a> with borders
  • Outlook may need extra VML if you insist on perfect pills
  • The link text should make sense out of context (“View the report”, not “Click here”)

Never put the only CTA inside an image map.

Hybrid / spongy stacking

Media queries fail in enough places that the default should already work on a 320px screen. Techniques:

  • Fluid images width=100% with max-width on the real pixel size
  • Single column layouts for newsletters that do not need a sidebar
  • For two columns, use stacked tables or hybrid ghost columns only if you will test Outlook

If the design requires a four-column product grid on mobile, it is the wrong design for email.

Accessibility that survives clients

  • Logical heading order in the content
  • Contrast on text and buttons
  • Alt text
  • role="presentation" on layout tables
  • Links that are not color-only
  • Language on <html lang="en"> (or the right lang)

Screen readers in Gmail and Outlook are imperfect. Semantic extras still help more than a 4KB spacer GIF.

Multipart and size

Send text/plain plus text/html. Some networks and people prefer text. Filters like seeing both. How to produce the text part: convert HTML to plain text.

Gmail clips around 102KB of the HTML. Inlined CSS, leftover comments, and duplicated tracking bloat you into that cliff. Measure. Cut unused modules.

ESP templating

Keep display logic simple. Nested conditionals that omit a closing table tag will break one segment only—the worst kind of bug.

Escape user-generated content. A contact named Jane <3 should not open a tag.

Put campaign URLs through a consistent UTM scheme (UTM builder).

What to stop copying from 2014 templates

  • Huge spacer GIFs for every gap
  • background="" on tables with no color fallback
  • “If you cannot see this email” as the preheader
  • Six social icons larger than the headline
  • Fake handwritten fonts as images for body copy

Templates should be short modules you can test once and reuse.

A starter HTML skeleton

You do not need a framework:

  • <!doctype html> and <html lang="…">
  • <meta charset="utf-8"> and a viewport meta if you use media queries
  • Body background color
  • Outer 100% table
  • Inner 600px table
  • Modules as rows: logo, heading, paragraphs, button table, footer

Each module should be deletable without breaking tags. That is how a developer removes a hero without taking the footer with it.

Comment <!-- module: footer --> if comments survive your ESP. Some strip them; that is fine.

Do not import a CSS reset meant for websites (* { box-sizing } wars). Email resets are small and specific: zero padding on body, table collapse, image borders.

Version the template. The second developer should not have to reverse-engineer Outlook fixes from a sent MIME file.

Copy, legal, and the footer module

Developers inherit last-minute legal paragraphs. Put them in a dedicated footer module with readable type (not 9px gray). Include:

  • Why the person is receiving the mail
  • Unsubscribe
  • Postal address when your counsel requires it
  • A preference link if you have one

Keep that module identical across campaigns so QA is once. Do not hide the unsubscribe to “protect the brand.” You will pay in complaints.

The same footer should survive forwarding: no text-on-background-image as the only copy. If legal must appear, it must appear as live text.

When product, legal, and brand all edit the template, freeze a base and take changes as modules. Unreviewed one-off HTML is how Outlook regressions return.

FAQ

Can we use MJML or similar compilers? Yes, if you still test the compiled table output. Compilers do not excuse you from Outlook.

Is CSS gap safe yet? Do not use it as the column system. Tables still win.

Should every email be dark-mode perfect? Aim for readable. Perfect inversion is not available in every client.

Do we need a live text version if HTML is accessible? Yes. Accessibility and multipart are cousins, not substitutes.

How often should we rebuild the base template? When bugs accumulate or brand type changes—not every campaign.

Related reading