When crafting HTML email templates, adding a preheader—a snippet of text that gives your recipients a preview of your email’s content—is crucial for better email engagement. This preheader typically shows up in the inbox view, right next to the subject line, to encourage opens. However, if you’re not careful, this preheader might end up displaying within the email body, which is undesirable, especially when viewed in clients like Microsoft Outlook.
Outlook has its own way of rendering emails, often ignoring common CSS practices that work seamlessly with other email clients. This can lead to issues such as preheader text showing up within the body of the email when replying or forwarding. Fortunately, there’s a way to hide preheader text across email clients, including Outlook.
In this blog post, we’ll break down a simple, effective approach to hiding the preheader text in your emails while ensuring compatibility with various email clients.
What is a Preheader?
A preheader is the short summary text that follows the subject line when viewing an email in the inbox. It’s a vital element for increasing open rates because it gives recipients a sneak peek at your message.
However, you don’t want the preheader text to be visible in the actual email body. Most email clients handle this correctly when hidden using CSS, but Microsoft Outlook is a bit trickier because it uses Microsoft Word’s rendering engine, which behaves differently than web-based email clients.
The Problem with Outlook
Outlook tends to ignore or misinterpret common CSS properties like display:none
, which makes it challenging to hide preheader text properly. As a result, preheader text might still show up at the top of your email, disrupting your design or adding unnecessary text.
To prevent this, we need to write code that hides the preheader in all email clients while specifically addressing the quirks of Outlook.
Solution: Hiding the Preheader in Outlook
Here’s a code snippet that hides the preheader text effectively across all email clients, including Outlook.
<!--[if !mso]><!-->
<div style="display:none; color:transparent; max-height:0px; max-width:0px; opacity:0; overflow:hidden; mso-hide:all;">
PREHEADER
</div>
<!--<![endif]-->
Let’s break down this code and how it works:
1. Conditional Comments Targeting Outlook
The key to dealing with Outlook is conditional comments. These are specially designed comments that only Microsoft Outlook can read and interpret, and they allow us to apply different styles or content for Outlook versus other email clients.
<!--[if !mso]><!-->
:
This is a conditional comment that means “if the client is not Microsoft Outlook” (MSO stands for Microsoft Office). Everything between this comment and the closing comment (<!--<![endif]-->
) will be ignored by Outlook, but processed by all other email clients.
In other words, the styles and HTML inside this block will be ignored by Outlook, preventing the preheader from displaying there.
2. The Preheader Div Block
Inside the conditional comment, we use a <div>
tag to contain the preheader text. To ensure the text remains hidden in all email clients (not just Outlook), we apply several CSS styles:
<div style="display:none; color:transparent; max-height:0px; max-width:0px; opacity:0; overflow:hidden; mso-hide:all;">
PREHEADER
</div>
Here’s what each CSS property does:
display:none;
:
This hides the element completely. It won’t take up any space on the page and won’t be visible to the recipient. However, some email clients like Outlook may ignore this, so we add more styles to ensure it remains hidden.color:transparent;
:
This ensures that even if the text appears, it will be transparent and not visible.max-height:0px; max-width:0px;
:
These properties set the maximum dimensions of the element to zero. If for some reason the email client doesn’t respectdisplay:none
, this ensures the container is collapsed to zero size.opacity:0;
:
This makes the preheader text completely invisible by making it fully transparent.overflow:hidden;
:
This hides any content that might overflow from the container. If the preheader text somehow appears, this will clip it so it doesn’t disrupt the layout.mso-hide:all;
:
This is a special property specifically for Microsoft Outlook. It tells Outlook to hide this element, even if it ignores the other styles.
3. Closing the Conditional Comment
<!--<![endif]-->
This closes the conditional comment block. The entire block, including the <div>
and its contents, will be ignored by Outlook, but handled by other email clients.
How Does This Work Across Different Clients?
- Non-Outlook Clients:
All email clients besides Outlook will process the code inside the<div>
, but because of the CSS rules (display:none
,color:transparent
, etc.), the preheader will remain hidden. - Outlook:
Outlook will skip the entire block because of the conditional comment (<!--[if !mso]><!-->
), meaning it won’t even attempt to render the hidden preheader text. Additionally, themso-hide:all
property ensures that Outlook doesn’t display the preheader text.
Why Use This Method?
This method offers several benefits:
- Cross-Client Compatibility:
It hides the preheader text across all major email clients, ensuring a consistent appearance in your email design. - Specifically Addresses Outlook:
By using conditional comments and themso-hide:all
property, you avoid issues with Microsoft Outlook’s rendering engine while keeping the preheader hidden. - Clean and Simple:
The code is minimal and doesn’t require complex workarounds, making it easy to integrate into your existing email templates.
Conclusion
Hiding preheader text is essential for a polished, professional email. While most email clients respond well to standard CSS techniques like display:none
, Outlook often needs special attention. By combining CSS with Outlook-specific conditional comments, you can ensure that your preheader text remains hidden across all clients without any surprises.
Now that you know how to hide preheader text, you can improve your email marketing campaigns and ensure that your emails look clean and professional in every inbox, including the notoriously tricky Outlook.
By using the technique outlined above, you can deliver better-looking emails while avoiding the pitfalls of inconsistent email rendering across clients. Happy coding, and here’s to better email design!