Full answer
A web page runs in a browser that you can test. An email is shown by many different mail programs, web mail sites and phone apps. Each one cleans, rewrites or limits the HTML in its own way, and some use old rendering engines with weak CSS support. The safe way to write email is to use the simplest markup that works everywhere.
Common rules:
- No JavaScript. Mail programs remove scripts and most active content. Forms, video and many other features are not reliable either.
- Layout with tables. Nested
tableelements withrole="presentation"are still the most dependable layout method, because Flexbox and Grid have poor or unknown support in many clients. Usewidth,cellpadding,cellspacingandalignattributes together with CSS. - Inline styles. Many clients remove or ignore
styleblocks in the head, and some remove media queries. A build tool usually inlines the CSS intostyleattributes. Keep astyleblock only for progressive extras such as responsive rules. - Fixed, narrow width. About 600 pixels is the usual maximum width, with
max-width: 100%for small screens. Hybrid and fluid patterns add some flexibility. - Images need
alttext, explicitwidthandheight, anddisplay: block. Many clients block images by default, so the email must still make sense without them. Do not put important text only in images. - Safe fonts with fallbacks, because web fonts are often not loaded. Use absolute
httpslinks, and a plain text version for clients that need it. - Dark mode can change colours in unexpected ways. Test with transparent images and avoid pure text-in-image designs.
Testing matters more than for the web. Check the email in real clients or with a testing service, because behaviour differs and changes over time. The claims here are general. Check the current support for each client that matters to you.
The inner table is 600 pixels wide and centred. All styles are inline, so a client that removes the head styles still shows the same look. The button is a link styled with padding, which works more widely than a form button.
This sample was checked in one browser only. It does not prove how any mail client will draw it.
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" id="outer">
<tr><td align="center">
<table role="presentation" width="600" cellpadding="0" cellspacing="0" id="inner" style="max-width:100%;background:#ffffff;font-family:Arial,Helvetica,sans-serif">
<tr><td id="cell" style="padding:16px;font-size:16px;color:#222222">Welcome to the course.</td></tr>
<tr><td style="padding:0 16px 16px"><a id="cta" href="https://example.com/start" style="display:inline-block;padding:10px 16px;background:#0a58ca;color:#ffffff;text-decoration:none">Start now</a></td></tr>
</table>
</td></tr>
</table>Mail clients were not available, so the snippet was only run in Chrome. Support for CSS differs a lot between mail clients, so test in the clients your readers use. Run in Chrome 156 (headless) as a page; the snippet is wrapped in a minimal HTML document with doctype, charset and viewport meta tag. Two full runs gave identical results, and the measured values in the answer come from them.
Key points
- Mail clients rewrite and limit HTML and CSS.
- Use nested tables with role="presentation" for layout.
- Inline the CSS; head styles may be removed.
- No JavaScript; images may be blocked, so add alt text.
- Test in real clients.
Common mistakes
- Relying on a style block in the head and on Flexbox or Grid.
- Putting key information only in images.
- Testing in one browser and assuming all mail clients will match.
Follow-ups
- Why use role="presentation" on a layout table?
- How would you test an email before sending?
Tips
- Open with the reason: many different clients with limited and changing support.
- List the main rules: tables, inline CSS, no scripts, fixed width, image alt and fallbacks.