Writing HTML for email is not like writing HTML for the web. Browsers follow current standards and mostly agree with each other; mail clients do not. Some strip parts of your stylesheet, some use a rendering engine from another era, some rewrite your code for security or to add dark mode, and a small number ignore most of it. The result is a craft with its own rules: build with tables, inline critical styles, keep to a conservative set of properties and test in the clients your audience actually uses. This guide gives a working summary of what you can rely on, where the big clients differ, how to build responsive layouts that degrade gracefully, how to handle fonts and images, what to avoid and a practical testing workflow. Support changes with new versions of clients, so use this as a starting point and verify with a current compatibility reference and with real tests.
How clients differ
| Client | Rendering engine and behaviour | Practical effect |
|---|---|---|
| Outlook for Windows (desktop, classic) | Microsoft Word engine | No support for many modern properties; limited margin, padding, background and width behaviour; needs conditional markup for some effects |
| New Outlook and Outlook on the web | Browser-based engines | Much better support, but not identical to the old client |
| Gmail (web and apps) | Own sanitiser; supports a style block with limits | Strips unsupported rules; rejects the whole style block if it contains certain errors; clips large messages |
| Apple Mail and iOS Mail | WebKit | Excellent support, including modern CSS and media queries |
| Samsung, Yahoo, AOL and others | Varied | Mostly good, with quirks; test them |
| Dark mode in several clients | Colours are inverted or adjusted | Test both modes; see accessible HTML email and dark mode |
Market share differs by audience. Check the clients in your own reports, since a business-to-business audience may be heavy on Outlook and a consumer audience on Gmail and Apple Mail.
Structure: use tables
For a layout that holds in every client, build the skeleton from nested tables with explicit widths and set role="presentation" so that screen readers do not announce them as data. Use cellpadding, cellspacing and border attributes in addition to CSS. A common pattern is a centred wrapper of up to about 600 pixels wide with inner tables for rows and columns.
<table role="presentation" width="100%" cellspacing="0" cellpadding="0" border="0" bgcolor="#f4f4f4">
<tr><td align="center">
<table role="presentation" width="600" cellspacing="0" cellpadding="0" border="0" style="max-width:600px;width:100%;" bgcolor="#ffffff">
<tr><td style="padding:24px;font-family:Arial,Helvetica,sans-serif;font-size:16px;line-height:24px;color:#222222;">
Content goes here.
</td></tr>
</table>
</td></tr>
</table>Inline the important styles
Put critical styles directly on elements with the style attribute. Clients that drop or alter a style block still render the message acceptably. A <style> block in the head remains useful for media queries and for hover effects, which only some clients support. Build with a stylesheet and run an inliner as part of your build, then check the result; do not hand-inline hundreds of rules. Keep the HTML small, because Gmail clips messages over about 100 KB, which hides the footer and the unsubscribe link and breaks open tracking. See email length.
Properties: safe, risky and avoid
| Property or feature | Support | Advice |
|---|---|---|
| font-family, font-size, color, line-height, text-align | Broad | Safe; always give a font stack ending in a generic family |
| background-color and bgcolor | Broad | Use both, for Outlook |
| padding on td | Broad | Use padding on table cells, not on divs |
| margin | Patchy, particularly in Outlook | Avoid; use spacer cells or padding |
| width and max-width | Width is broad; max-width fails in old Outlook | Set width and use conditional markup for a fixed Outlook width |
| border, border-radius | Border broad; radius ignored in old Outlook | Treat radius as an enhancement |
| background-image | Broad outside Outlook; needs VML in old Outlook | Always set a background colour fallback; see images blocked |
| float, position, flexbox, grid | Poor or absent in several clients | Avoid for layout; use tables |
| CSS variables, calc() | Not reliable | Avoid |
| Media queries | Supported in Apple Mail, many mobile clients and Gmail apps (varies) | Use for enhancement, not as the only way to be readable on a phone |
| Web fonts (@font-face) | Apple Mail and some others; ignored elsewhere | Always provide a safe fallback stack |
| JavaScript, forms, iframes | Blocked in nearly all clients | Do not use |
| SVG images | Inconsistent | Use PNG or JPEG for important graphics |
Responsive without breaking
There are two complementary approaches. Fluid layouts use percentage widths and a maximum width so that the content scales down to the screen. Media queries restyle the layout for small screens, for instance stacking columns and enlarging buttons. A robust strategy is to make the default layout work on a narrow screen without any media query, with a single main column and large tap targets, and to use media queries and conditional markup to enhance the desktop view where supported. Gmail on some account types does not support media queries, so a design that depends on them will break there. Keep body text at 14 to 16 pixels or larger, buttons at least 44 pixels tall and links separated enough to tap.
Outlook-specific techniques
- Conditional comments target the Word engine:
<!--[if mso]> ... <![endif]-->lets you give Outlook a fixed-width table or VML shapes while other clients ignore it. - mso- properties such as
mso-line-height-rule: exactlyfix line spacing issues. - Image sizing: set explicit
widthandheightattributes; Outlook may ignore CSS sizes and may scale images using dots-per-inch metadata. - Buttons: use the table-cell button pattern, or VML for rounded buttons.
- Test the classic desktop version specifically; web and new versions behave differently.
Fonts and colour
Rely on system fonts (Arial, Helvetica, Georgia, Verdana, Tahoma, Times New Roman, Trebuchet MS) in a stack, such as font-family: "Segoe UI", Arial, Helvetica, sans-serif. If you add a web font, the stack must still look acceptable if the font fails to load. Use sufficient colour contrast (a ratio of at least 4.5 to 1 for body text) and do not rely on colour alone to convey meaning. Specify both text and background colours explicitly so that dark mode adjustments do not produce unreadable combinations.
Common mistakes
Teams new to email development repeat a few errors. They design in a browser and assume the result holds everywhere. They use margins for spacing and find the layout collapsed in Outlook. They rely on a hero image for the message and see an empty box when images are off. They paste a large web page template with many unused rules and trigger Gmail clipping. They forget that the footer and the unsubscribe link must remain visible. And they test only on their own phone. Keep a short checklist beside the template, covering structure, inlining, fallbacks, size and testing, and review every new design against it before it is sent to a real list.
Testing workflow
- Build a base template and keep it under version control.
- Run an inliner and a validator as part of the build.
- Send to real accounts in Gmail (web and app), Outlook (classic, new, web and mobile), Apple Mail on desktop and iPhone, and one Android client. A rendering preview service helps with coverage, but real accounts settle disputes.
- Check with images off, in dark mode and at narrow widths.
- Test the plain-text version and the headers; see HTML email templates.
- Run the finished message through the spam checker.
- Keep a log of known quirks and fixes in your team documentation.
Email CSS is not glamorous, but its rules are stable enough to learn. Use tables, inline what matters, treat modern CSS as enhancement and test in the clients that count. The templates that follow these habits survive client updates with little change.
Send your templates through a reliable pipeline Multipart HTML and text with correct encoding, via the relay or the API.
References and further reading
Frequently asked questions
Why does my email look different in Outlook?
Classic desktop Outlook uses the Word rendering engine, which ignores many modern CSS properties. Use tables, inline styles and conditional markup.
Should I use inline CSS in email?
Yes for critical styles. Keep a style block for media queries and enhancements, and inline with a tool as part of your build.
Do media queries work in Gmail?
Support varies by account type and app. Design a layout that is usable without them.
Can I use web fonts in email?
Only as an enhancement. Always provide a fallback font stack, since many clients ignore web fonts.
How should I test an HTML email?
Send to real accounts in Gmail, Outlook, Apple Mail and Android clients, with images off and in dark mode, and use a rendering preview for extra coverage.