Sub topic 3
Writing and Hiding Preheader Text
Assume you know basic HTML, CSS media queries, and how email clients deliver messages. This chapter focuses on the finishing details that often decide whether a template works consistently.
Writing and Hiding Preheader Text
A preheader is the short preview shown beside or below the subject in many inboxes. It should extend the subject with useful information, not repeat it.
Place it near the start of the body. Hide it visually while keeping it available to inbox software. Extra nonbreaking spaces and zero-width characters help prevent later body text from appearing in the preview.
<div style="display:none;max-height:0;overflow:hidden;opacity:0;
mso-hide:all;font-size:1px;line-height:1px;color:#f4f4f4;">
Your order has shipped and should arrive Friday. ‌ ‌
</div>Outlook Fallbacks with Conditional Comments
Desktop Outlook uses Microsoft Word to render much of its HTML. It may ignore max-width on a div. Conditional comments let you provide Outlook-only markup while other clients use the fluid version.
<!--[if mso]>
<table role="presentation" align="center" width="600" cellpadding="0"
cellspacing="0" border="0"><tr><td>
<![endif]-->
<div style="width:100%;max-width:600px;margin:0 auto;">
Email content
</div>
<!--[if mso]>
</td></tr></table>
<![endif]-->Supporting Dark Mode
Declare supported color schemes, then override colors in a media query. Use !important because clients may apply their own transformations.
<meta name="color-scheme" content="light dark">
<meta name="supported-color-schemes" content="light dark">
<style>
@media (prefers-color-scheme: dark) {
.email-bg { background-color:#121212 !important; }
.email-text { color:#f1f1f1 !important; }
}
</style>Dark-mode support varies. Test both explicit dark mode and clients that automatically invert colors.
Accessibility Basics for Email
Use lang="en" on the root element. Give informative images useful alt text, and use alt="" for decorative images. Set sufficient text contrast. Use real links for actions, not only JavaScript or image maps. Mark layout tables with role="presentation" so screen readers do not announce them as data tables.
Testing Across Clients and Devices
Test the actual sent message, not only the source file.
| Test area | Check |
|---|---|
| Desktop | Gmail, Outlook, and Apple Mail |
| Mobile | Narrow and wide phone screens |
| Modes | Light mode, dark mode, and blocked images |
| Content | Long text, missing images, and keyboard navigation |
A useful workflow is to validate the HTML, send test messages, inspect screenshots, and check links and accessibility manually.
Exercise
Why should a preheader include hidden filler characters?
Show answer
They reduce the chance that visible body text fills unused preview space after the intended preheader.