Skip to content

Instantly share code, notes, and snippets.

@jamesmacwhite
Last active October 12, 2023 11:05
Show Gist options
  • Star 32 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jamesmacwhite/18e97b06f2c04661a757 to your computer and use it in GitHub Desktop.
Save jamesmacwhite/18e97b06f2c04661a757 to your computer and use it in GitHub Desktop.
Hiding content with mso-hide:all; to be more friendly with Outlook.com

The mso-hide:all; workaround for conditional content hiding with Outlook (Desktop client)

Outlook.com strips all content in ANY conditional comment placed in an email template. Depending on how your logic is constructed, this can be a problem, as it will potentially remove content that you intend to be visible.

There are various articles that suggest clever modification of conditional comments resolve the problem.

THIS IS NO LONGER TRUE!

Conditional comments will be stripped regardless.

<!--
Example 1: Using IF ELSE logic
Works with Outlook (Desktop)?: Yes
Works with Outlook.com?: No
When using IF ELSE logic, Outlook.com will remove content in both conditionals, which is problematic.
-->
<!--[if mso]>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>Special Outlook (Desktop) content</td>
</tr>
</table>
<![endif]-->
<!--[if !mso]><!-- -->
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>All other clients</td>
</tr>
</table>
<!--<![endif]-->
<!--
Example 2: Using one IF statement and mso-hide:all;
Works with Outlook (Desktop)?: YES
Works with Outlook.com?: YES
This example only uses IF logic. This will work OK with Outlook.com because the conditional is targeting the Outlook desktop
client only. Outlook.com will still strip the content but it doesn't matter in this case because the conditional isn't targetting
that client.
However because the MSO conditional comment logic has been removed in order to hide the second table in Outlook (Desktop)
the special MSO property of mso-hide:all; must be used in replacement of !mso
-->
<!--[if mso]>
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td>Special Outlook (Desktop) content</td>
</tr>
</table>
<![endif]-->
<table border="0" cellpadding="0" cellspacing="0" width="100%" style="mso-hide:all;">
<tr>
<td>All other clients</td>
</tr>
</table>
<!-- Note when hiding nested table content you will need to apply mso-hide:all; to the containing and nested tables within -->
@CurrinCoursera
Copy link

Works great! Thank you so much!!

@Daddyjohn63
Copy link

Fantastic ! thank you so much !!

@dalailomo
Copy link

Tnx mate, works like a charm

@sicin
Copy link

sicin commented Jul 6, 2021

Thanks! It's great!

@KamilSalic
Copy link

thank you, it is really helpful

@Chanduchinna
Copy link

If an email is opened using browser outlook (not outlook app) this function doesn't work. Is there a way we can hide in browser outlook also?

@daniil-filippov-lans
Copy link

If an email is opened using browser outlook (not outlook app) this function doesn't work. Is there a way we can hide in browser outlook also?

You can try style="mso-hide:all;visibility:hidden;" it works well in browser and desktop outlook

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment