Sub topic 8
Setting Preview Text in HTML Email
This chapter assumes you can edit the HTML of an email template and know what an open rate is. It covers how to set preview text in the HTML itself, what goes wrong, and how to check the result before you send.
What the preheader is
Preview text is the snippet an inbox shows next to or under the subject line. In HTML email it is often called the preheader. If you set nothing, most email clients take the first run of readable text in the body. That is often "View this email in your browser" or a navigation link, which wastes the space.
To control the snippet, put the text you want at the very top of the <body>. Then hide it from the visible layout. The inbox still reads it, but the reader of the opened email does not see it.
Some email platforms offer a preview text field in their editor. Those tools usually insert the hidden block for you. Knowing the markup matters when you use a custom template, when the field is missing, or when the preview looks wrong.
The basic hidden preheader
<body>
<div style="display:none;max-height:0;overflow:hidden;opacity:0;mso-hide:all;">
Free shipping on orders over $50 applies at checkout.
‌ ‌ ‌ ‌ ‌ ‌
</div>
<!-- visible email content follows -->
</body>Each part of the style attribute has a job:
| Property | Purpose |
|---|---|
| `display:none` | Removes the block from the visible layout in most clients. |
| `max-height:0` | Collapses the block in clients that ignore `display:none`. |
| `overflow:hidden` | Clips any content that would spill out of the collapsed block. |
| `opacity:0` | Makes any remaining rendering invisible. |
| `mso-hide:all` | Hides the block in Microsoft Outlook desktop clients, which use the Word rendering engine. |
The block must be the first thing inside <body>. Any visible text placed before it, such as a logo's alt text or a "view in browser" link, will be read first and can take over the snippet.
Why the padding characters are there
Inbox clients show a fixed number of characters, and the number varies by client and device. If your preheader is shorter than that, the client keeps reading and fills the rest of the line with the next text it finds. That text is often the start of the visible body, such as a greeting or a header. The result can read as a clumsy join: "Free shipping on orders over $50 applies at checkout. Hi Sam, welcome back".
The fix is to follow the preheader with characters that take up space but show nothing. The example uses (a non-breaking space) alternating with ‌ (a zero-width non-joiner). Alternating them stops some clients from collapsing a run of identical whitespace. The padding pushes the body text beyond the visible preview.
Here is a small script that generates the block with enough padding. It runs as shown with Python 3.
def build_preheader(text: str, target_length: int = 150) -> str:
"""Return a hidden preheader div padded to roughly target_length characters."""
hidden_style = (
"display:none;max-height:0;overflow:hidden;"
"opacity:0;mso-hide:all;"
)
pad_units_needed = max(0, target_length - len(text))
padding = " ‌" * (pad_units_needed // 2)
return f'<div style="{hidden_style}">{text}{padding}</div>'
if __name__ == "__main__":
block = build_preheader("Free shipping on orders over $50 applies at checkout.")
print(block)Each ‌ pair counts as two characters in the preview, so the function divides the shortfall by two. The target of 150 is a safe ceiling. It is not a rule, and clients differ. Some show under 50 characters on a phone and over 100 on a desktop.
Escaping and special characters
The preheader is HTML, so treat its text like any other body content.
- Write
&as&, and<as<, or the markup may break. - A literal
$is fine. In templating languages that use$or braces for variables, check that your tool does not try to interpret it. - Emoji work in most clients, but they can render differently or as boxes in older ones. Test them.
- Keep the text on a sensible length. A preheader of about 40 to 90 characters covers most views. Put the important words first, the same front-loading rule that applies to subject lines.
Dynamic content and fallbacks
If you build the preheader from merge fields, such as a first name or a product name, a missing value produces broken text. For example, "Sam, your cart is saved" becomes ", your cart is saved" if the name is empty.
Give every merge field a fallback. In many templating systems this looks like a default value in the tag. The exact syntax depends on your platform, so use your tool's own form. Then send a test with an empty field to prove the fallback works.
A related error is leaving placeholder text in the template. A preheader that reads "Preheader text goes here" is a common and avoidable mistake. Search your template for it before sending.
Common errors
- Visible preheader. The hidden style was stripped, often because an editor or a CSS inliner removed inline styles, or the block sits inside an element that restores display. The fix is to keep the inline style on the element itself, since many clients ignore or remove
<style>blocks in the head. - Body text leaking into the preview. The padding is missing or too short. Add more padding and check again.
- Preheader not first. Something earlier in the body, such as a tracking element with text or a banner, supplies the snippet. Move the block to the top.
- Repeating the subject. The technical setup is correct, but the text adds nothing. The next chapter covers how to write the two as a pair.
- Preheader appears at the top of the opened email. This happens in clients that ignore
display:nonein some contexts, or when plain-text rendering is used. Check the text-only version too. - Different results by client. Gmail, Apple Mail, Outlook and mobile apps each truncate at a different point. One render is not proof.
Do not forget the plain-text version
Many sending platforms build a multipart message with an HTML part and a plain-text part. Some clients display the plain-text part, and some accessibility tools read it. In the plain-text part, the preview comes from the first lines. Put a short, meaningful first line there, or the first text a reader sees may be a long URL.
Also keep in mind that screen readers can read the hidden preheader aloud in some cases, because hiding with CSS does not always remove text from assistive technology. Writing a real, useful sentence rather than filler keeps that experience sensible.
A reliable setup workflow
The diagram shows the steps from writing the text to a verified send.
Testing the result
Send test messages to real accounts, not only an in-tool preview. At minimum, check:
- Gmail on the web and on a phone.
- Apple Mail on iPhone or Mac.
- An Outlook client, if your audience uses it.
- A dark-mode view, to confirm the hidden block does not become visible.
For each test, read the sender name, subject line and preview text together. They should make sense as one unit. If the preview shows a stray link, a greeting, or the wrong text, return to the common errors list.
If you send to large lists, an inbox preview tool can render many clients at once. It saves time, but real accounts remain the final check, because rendering tools approximate each client.
Edge cases
- Very short preheaders. A preheader of a few words plus padding is fine. Padding exists to prevent leakage, so short text does not need to be lengthened with filler words.
- Intentionally blank previews. Some senders want no snippet. A block holding only padding characters can suppress the body text, but a blank preview wastes a place to add a reason to open, so use it rarely.
- Templates reused across campaigns. The preheader is easy to forget when you duplicate an old email. Copying the previous campaign's text is a common error. Make the preheader part of your review step.
- Forwarded and archived copies. The hidden text stays in the HTML. Do not put anything in it that you would not want read in the source.
Summary
Place a hidden block first in the body. Style it inline with display:none, max-height:0, overflow:hidden, opacity:0 and mso-hide:all. Follow the text with alternating and ‌ padding so the body text does not leak into the snippet. Escape special characters, give merge fields fallbacks, check the plain-text part, and verify in several real clients.
Exercise
Your preheader text is "Free shipping on orders over $50 applies at checkout." On a test send, the inbox shows "Free shipping on orders over $50 applies at checkout. Hi Sam, welcome back". Name the cause and give two fixes.
Show answer
The preheader is shorter than the number of characters the client shows, so the client continues into the visible body text ("Hi Sam, welcome back"). Fixes: add padding after the preheader text using alternating and ‌ characters so the body text falls outside the visible preview, and make sure the hidden block is the first element in the body. Lengthening the preheader with a real, useful sentence also helps.
Exercise
A colleague writes the hidden block with a <style> rule in the document head, .preheader { display:none; }, and the preheader appears at the top of the email in one client. What should they change, and why?
Show answer
Move the hiding rules into an inline style attribute on the element itself, including max-height:0, overflow:hidden, opacity:0 and mso-hide:all. Some clients strip or ignore <style> blocks in the head, so the class rule is not applied and the text shows. Inline styles survive in more clients, and the extra properties cover clients that ignore display:none.
Exercise
A preheader built as "{{first_name}}, your cart is saved" shows ", your cart is saved" for some recipients. How do you prevent this, and how do you confirm the fix?
Show answer
Add a fallback value for the merge field, using your platform's default-value syntax, such as a neutral word or a version of the sentence that does not need a name. Then send a test message to a contact record whose first name field is empty, and check that the preview reads correctly.