Search code examples
htmlcssoutlookhtml-emailfont-size

Outlook ignoring font size


Using:

<html>
<head>
<style>
  p {
    font-size: 16px;
  }
  .font-size-16 {
    font-size: 16px !important;
  }
</style>
</head>
<body>
  <p>Duis eros mauris, sodales et ullamcorper ac, ultrices vitae mi. Morbi scelerisque tristique nibh, eget venenatis erat mattis maximus. Donec vestibulum auctor consectetur.</p>
  <!--[if mso]>
    <v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="https://example.com/contact/support/" style="font-family: Verdana, Geneva, sans-serif; height: 54px !important; width: 125px !important; padding-top: 10px; text-decoration: none; background-color: #2747d7!important; color: #fff !important; v-text-anchor:middle;" arcsize="20%" strokecolor="white" fillcolor="#2747d7">
        <w:anchorlock/>
        <center class="font-size-16" style="color:#ffffff; font-size:16px;">Contact us</center>
    </v:roundrect>
  <![endif]-->
</body>
</html>

the paragraph font size always displays as 16px but the <v:roundrect><center> displays in a variety of different font sizes, usually about 2px smaller, over different versions of Outlook.

How do we achieve a consistent font size in Outlook in general, and as a style for <v:roundrect><center> in the above example?

From this answer, I've removed !important; from the inline style and added a style to the <head> but the issue remains.

Help appreciated.

Solution

Nathan's answer prompted the solution:

<style>
    body {
        font-family: Verdana, Geneva, sans-serif;
        font-size: 16px;
    }
</style>
<!--[if mso]>
<style>
    .font-size-override-button {
        font-size: 12pt !important;
        text-decoration: none;
    }
</style>
<![endif]-->

<!--[if mso]>
<v:roundrect xmlns:v="urn:schemas-microsoft-com:vml" xmlns:w="urn:schemas-microsoft-com:office:word" href="https://www.example.com/contact/support/" style="height:39px;v-text-anchor:middle;width:125px;" arcsize="30%" stroke="f" fillcolor="#2747d7">
    <w:anchorlock/>
    <center>
    <![endif]-->
        <a href="https://www.example.com/contact/support/" class="font-size-override-button" style="background-image: linear-gradient(90deg, #2747D7 0%, #6127E7 51%, #2747D7 100%) !important; background-position-x: 0 !important; background-position-y: 0 !important; background-repeat: no-repeat !important; background-size: 200% auto !important; background-color: #2747d7 !important; border-radius:8px;color:#ffffff;display:inline-block;font-family:Verdana,Geneva,sans-serif;font-weight:bold;line-height:39px;text-align:center;text-decoration:none;width:125px;-webkit-text-size-adjust:none;">Contact us</a>
    <!--[if mso]>
    </center>
</v:roundrect>
<![endif]-->

Solution

  • Try pt instead of px. When there's different versions of Outlook showing different things, that's usually it. 3pt = 4px, so 12pt = 16px.

    i.e. <center style="color:#ffffff; font-size:12pt;">Contact us</center>

    I think you'll also need this in the head if it isn't already:

    <html lang="en" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml"  xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
    <!--[if mso]><xml>
      <o:OfficeDocumentSettings>
        <o:AllowPNG/>
        <o:PixelsPerInch>96</o:PixelsPerInch>
      </o:OfficeDocumentSettings>
    </xml><![endif]-->