Skip to main content

Our email CSS engine is open source. Give it a star on GitHub 

Emailens
Blog

Outlook HTML Email: MSO Conditional Comments and mso- CSS

Wrap markup meant only for Outlook Classic in <!--[if mso]> comments, hide markup from it with <!--[if !mso]><!-->, and use mso- properties such as mso-line-height-rule and mso-table-lspace to correct how Word spaces lines and tables.

The fix for Outlook Classic

Use VML to render rounded buttons in Outlook

after
<!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml"
  href="https://example.com"
  style="height:44px; v-text-anchor:middle; width:200px;"
  arcsize="14%" strokecolor="#6d28d9" fillcolor="#6d28d9">
  <w:anchorlock/>
  <center style="color:#fff; font-family:Arial,sans-serif;
    font-size:14px; font-weight:bold;">Click Here</center>
</v:roundrect>
<![endif]-->
<!--[if !mso]><! -->
<a href="https://example.com"
  style="background-color: #6d28d9; color: #fff;
         padding: 12px 32px; border-radius: 6px;
         text-decoration: none; display: inline-block;">
  Click Here
</a>
<!-- <![endif]-->
Show the original
before
<a href="https://example.com"
  style="background-color: #6d28d9; color: #fff;
         padding: 12px 32px; border-radius: 6px;
         text-decoration: none; display: inline-block;">
  Click Here
</a>

The checker needs a computer screen.

A free account opens all 21 clients and keeps your checks for 7 days. Create a free account →

Real installs

Philippe Kam, founder of Emailens · Published 4 Mar 2026 · Updated 28 Oct 2026

@emailens/engine 0.18.22 · data last changed 10 Nov 2026

Part of the HTML email guide · all guides

An Outlook HTML email carries code that only Outlook Classic reads: MSO conditional comments, which show or hide markup for Outlook alone, and mso- CSS properties, which correct how Word spaces lines and tables. Every other client ignores both. This is how each one works and where it goes in a template. (Looking for Outlook's own template feature? See how to create an email template in Outlook.)

Why Outlook needs its own code

Outlook Classic on Windows renders email with Microsoft Word, while Outlook on the web, on a Mac and the new Outlook for Windows use browser engines. Which Outlook uses which engine, and what Word does with each CSS property, is in the Outlook CSS support guide. This page is the tools for writing markup Word alone will read.

MSO conditional comments: markup only Outlook reads

Outlook respects Microsoft's old conditional-comment syntax. Anything between <!--[if mso]> and <![endif]--> is read by Outlook Classic ("mso" stands for Microsoft Office) and treated as an ordinary HTML comment by every other client, the new Outlook included.

mso-only.html
7 lines
<!--[if mso]>
  <table role="presentation" width="600"><tr><td>
<![endif]-->
  ...content every client sees...
<!--[if mso]>
  </td></tr></table>
<![endif]-->

Here the comment hands Outlook a fixed 600px table around content everyone sees. The condition can also compare versions, as in <!--[if gte mso 9]> (gte: greater than or equal), the form the VML snippets in the background-image and gradient guides open with.

Hiding content from Outlook with [if !mso]

The reverse, markup every client renders except Outlook Classic, needs a slightly odd form. <!--[if !mso]><!--> opens a condition for Outlook and closes the comment straight away for everyone else, so other clients render what follows; <!--<![endif]--> ends it. Put the two blocks side by side and each client gets exactly one version:

mso-split.html
7 lines
<!--[if mso]>
  ...markup for Outlook Classic only...
<![endif]-->

<!--[if !mso]><!-->
  ...markup for every other client...
<!--<![endif]-->

This is how a rounded button ships a VML <v:roundrect> to Outlook and a CSS link to everyone else; the full button is in border-radius in Outlook.

Where conditional comments go in an Outlook template

  • In the head. Word's document settings, inside a conditional comment. The <o:PixelsPerInch>96</o:PixelsPerInch> line keeps Word on a 96 DPI baseline, so VML shapes do not grow when Windows display scaling is set to 125% or 150%.
  • On the html tag. The VML and Word namespaces, xmlns:v="urn:schemas-microsoft-com:vml" and xmlns:w="urn:schemas-microsoft-com:office:word", if the email uses VML.
  • Around columns. A fixed-width table for Outlook around inline-block columns: Outlook ghost tables.
  • Around VML. Rounded buttons and gradients (Outlook CSS fallbacks) and background images (background images in Outlook).
head.html
9 lines
<!-- Inside the <head> of the email -->
<!--[if mso]>
<xml>
  <o:OfficeDocumentSettings>
    <o:AllowPNG/>
    <o:PixelsPerInch>96</o:PixelsPerInch>
  </o:OfficeDocumentSettings>
</xml>
<![endif]-->

mso- CSS properties for Outlook

Word reads a set of proprietary CSS properties that other clients ignore. They fix spacing that Word gets wrong:

mso-line-height-rule: exactly

Forces exact line-height rendering. Without this, Outlook may add extra space above and below text.

mso-table-lspace: 0pt

Removes default left spacing Outlook adds to tables.

mso-table-rspace: 0pt

Removes default right spacing Outlook adds to tables.

mso-padding-alt

Alternative padding for Outlook when standard padding is ignored on certain elements.

mso-width-percent: 1000

Word's percentage width, in tenths of a percent: 1000 is 100%. Used on VML shapes, which ignore width: 100%.

Put mso-table-lspace: 0pt; mso-table-rspace: 0pt; on every layout table, next to border-collapse: collapse; together they are part of the fix for Outlook's thin lines across table columns, described in Outlook CSS fallbacks.

Build the layout with tables

For Word-based Outlook, tables are the only reliable layout mechanism: every row, column and content block is a <table>, <tr> and <td>. MJML and React Email compile to tables for you; the Outlook CSS support guide shows both.

Questions

What does <!--[if mso]> mean in an HTML email?

It opens a conditional comment. Outlook Classic on Windows reads what sits between <!--[if mso]> and <![endif]--> as markup ('mso' stands for Microsoft Office); every other client sees an ordinary HTML comment and skips it.

How do I hide content from Outlook?

Wrap it in <!--[if !mso]><!--> and <!--<![endif]-->. Outlook Classic skips everything in between, while other clients see two empty comments and render the content. Pair it with an <!--[if mso]> block to give Outlook its own version.

What are mso- CSS properties?

Microsoft Office CSS extensions like mso-line-height-rule: exactly; and mso-table-lspace: 0pt; tell Word's rendering engine to fix line height miscalculations and remove unwanted table cell margins.

Do conditional comments affect Gmail, Apple Mail or the new Outlook?

No. To them an <!--[if mso]> block is a comment, so it costs nothing but bytes. The new Outlook for Windows renders with a browser engine and reads them as comments too, so the code inside is for Outlook Classic alone.

Your next question

Also useful: Outlook Ghost Table Generator · Bulletproof Button Generator · Free HTML email templates, tested in 21 clients

Paste the email that broke.

The checker needs a computer screen.

Every account includes one free real-device check in classic Outlook, Outlook for Mac and Apple Mail, after you verify your email and run one preview, while this month's free capacity lasts. How real-device checks work →

Get new email CSS fixes by email, or follow by RSS.