Vector Markup Language and Backgrounds

Background Check

Backgrounds might seem like they should be a simple effect to achieve in HTML email, but that’s not always the case. Outlook 2007, 2010 and even 2013 will give users who rely on the TD background-image property a lot of trouble. Because of these problems many have turned to Vector Markup Language (VML), part of the Office Open XML standards. VML has mostly been scrapped in favor of SVG, but older email clients still use it. Campaign Monitor covered the following ways to implement VML for email backgrounds, but we’re going to add one more trick to that list at the end of this blog. Let’s start with this custom Mictrosoft HTML namespace declaration:

<html xmlns:v="urn:schemas-microsoft-com:vml">

This namespace declaration is necessary to make sure VML capable clients render your VML properly.


Table Cell Backgrounds – Fixed Width

Given the prevalence of table-based email design, it won’t be long before you want to apply a background to a table cell. Remember to include the namespace declaration we covered above. This example uses a conditional statement to target Outlook clients, as well as the proprietary TD “background” attribute. TD’s without background will not show an image in and Lotus Notes. The fix below only works on TD’s with a fixed width, we’ll cover fluid width TD’s next.

 <html xmlns:v="urn:schemas-microsoft-com:vml">
 <table width="600">
     <td bgcolor="#363636" style="background-image: url('');"
       background="" width="540" height="150">
       <!--[if gte mso 9]>
       <v:rect style="width:540px;height:150px;" strokecolor="none">
         <v:fill type="tile" color="#363636" src="" /></v:fill>
       <v:shape id="NameHere" style="position:absolute;width:540px;height:150px;">
     <p>This text should appear on top of your background image.</p>
       <!--[if gte mso 9]>

Table Cell Backgrounds – Percentage-Based Width

It gets a bit trickier to create a tiling background for a TD with percentage-based width. We found that the v:rect element wouldn’t take width:100% or width:full as width values. Instead, the  mso-width-percent style can be used to create a fluid width background. It might look confusing at first, but  mso-width-percent is actually quite simple. The number you need to pass to it is ten times the percentage you’d like. This means that  mso-width-percent: 1000; is actually 100%, or full page width. For 50% one would enter  mso-width-percent:500;. Remember to change these values on both the TD and VML shape elements when modifying this code.

 <table width="100%">
     <!-- Backup background color is #dddddd -->
     <td bgcolor="#dddddd" style="background-image: url('');background-repeat:repeat-x; background-position: bottom left;"
       background="" width="100%" height="30">
       <!--[if gte mso 9]>
         <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="mso-width-percent:1000;height:30px;">
           <v:fill type="tile" src="" color="#f6f6f6" />

It’s not pretty, but it works. Even with tricks like these, backgrounds provide email designers with no shortage of challenges. What background quirks have gotten your goat? Let us know in the comments below.

37 thoughts on “Vector Markup Language and Backgrounds”

  1. This is a good pointer – however, the problem is made worse if you only need to use a table cell background which fits the content – for some reason, the mso-width-percent:1000 ends up making the cell much wider than it needs to be!

  2. RWAP01,
    You should take a look at the “Table Cell Backgrounds – Fixed Width” section, which has the code for fixed width table cells. “mso-width-percent:1000” is for 100% width cells.

  3. I have looked at that, but for some reason, having added that, the table cell is much much wider than the content (which is just a text link!)

    My guess is that mso-width-percent:1000 is still looking for the fixed width of the table cell (which I do not have).

  4. RWAP01,
    Did you remember to modify the width in all three places? The TD, the v:rect and the v:shape?

  5. RWAP01,
    You shouldn’t be using mso-width-percent:1000 in a fixed width table cell. Express the width in px in all 3 places (TD, v:rect, v:shape) and it should work properly.

  6. Hmm – I can see the misunderstanding – the problem is that I do not know the fixed cell width – I was trying to use the same code in several emails – each of which may have different length text in the link – ie. the width of the column actually reflects how much text is in it, so it cannot be fixed width.

    This is actually for a three image button (as you can do in HTML), with a div for the left and right hand sides of the button, each containing an image, and a middle div with a background image.

    The problem is that the text in the button can vary dependent on circumstances

    Reading between the lines, this is not possible – the vml controls for the image either need a fixed width setting, or a % width based on the width of the table (?).

    I guess I will have to use different code in each email dependent upon the text used in the column.

  7. Thanks a bunch for this!
    I was told by our lead designer after presenting my initial email redesign mock-up, that background images weren’t a ‘thing’ in email.
    Where there’s a will, there’s a way, and I’ve managed to match his design for our website using this technique.

  8. This works very well BUT when I click on NEW for a new email in Outlook 2013, it takes 10 seconds to come back with my fantastic VML signature… any ideas?

  9. Thanks for this, it’s a big help!

    Any ideas about how to change dimensions for mobile?

    My image is in a 100% width table, inside a 600px container. I’m using CSS media query in the header to change width for mobile. If I change the image table to 600px width and use <!–[if gte mso 9]> inside my table, the image is too large for mobile. Is there another kind of conditional to use in the html for mobile in addition to <!–[if gte mso 9]>, or a way to put VML inside css instead?

  10. Has anybody figured out how to keep the background-image centered when using this full-width solution? As is, it aligns left.

  11. Hello 🙂

    the fixed-code makes me really happy after hours of time-wasting to get outlook to show my images.
    but i have one little prob, maybe you could help.

    td / vml-code/ image have all the same size 95px x 642px, but in outlook the backgound-image is shown more than once in a smaller version. can i use something like repeat?

    thank you so much 🙂

  12. I really appreciate this helpful info, but I am having an annoying problem.

    I am using a fixed width/height cell and setting the width/height in all three places (TD, v:rect, v:shape) as described above, but my image always shows blown up larger for some reason.

    The image itself is the exact width/height of the TD, rect, shape, but it is displaying larger.

    Any ideas?

  13. It doesn’t work at all for me. The background images don’t load.

    It seems that the problem is the namespace declaration is stripped out of emails when they are sent. When I look at the source code, I don’t it anymore.

    Any idea how to stop this?

  14. Sean,
    If your ESP is stripping code that you need, I’d talk to them about it. You may want to switch your ESP to somebody who won’t modify your code.

  15. I can’t get this code to work on Outlook 2010.

    On the “Table Cell Backgrounds – Percentage-Based Width” snippet, where should I add my content, right after the “

  16. Hi Geoff, thanks for replying to my email. I went ahead and emailed my code snippet via I appreciate your help. Thanks man.

  17. Hi Geoff, for some odd reason my background images still don’t render in Office 2010. Any ideas? Here is my code:

    <html xmlns:v="urn:schemas-microsoft-com:vml">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0;">
    <!--[if gte mso 9]>

    < ![endif]--> <!-- HEADER GRAPHIC START -->

  18. <!--[if gte mso 9]>

    < ![endif]-->

    <!--[if gte mso 9]>

    < ![endif]-->

  19. Hi,

    I’m having issues with Outlook 2013 where the VML background doesn’t show in the preview pane. If you open the email up, it appears fine. Any ideas?

    Cheers, Daz

  20. Daz,
    Wish I could help you more, but I am not an expert in VML. Seems like the preview pane should show the same thing, but who knows what they were thinking!

  21. Thanks for your hard work Geoff. I’m trying to use the full-width VML code, but it appears to show the bg image at the top, with overlaying text (a separate table inside the TD that holds the bg image) underneath it. This makes it look tall. Here’s what it looks like:

    Here’s my html:

    <html xmlns:v=”urn:schemas-microsoft-com:vml”>

  22. <!–[if gte mso 9]>

    < ![endif]-->


    Welcome Jamie

    Your adventure starts here

    <!–[if gte mso 9]>

    < ![endif]-->

    Any ideas what’s causing the bg image to stack over the overlaying table in it? Thanks in advance!

  23. I’m not sure if you notice, but if you’re using a fixed-width bg image with text/image inside an inner table that’s overlaying it, if the valign attribute of the TD that holds the bg image is not set to “top” (in my case it was set to “bottom”), the bg image will left-align, not centered.

    David Condrey, is the bg image in the TD set to valign=”bottom” or “middle”? If so, try setting it to “top”. In my case, since I have an inner table that holds overlaying copy and image, I added an empty table “spacer” and set the height to a value that helps push down the overlaying table.

  24. This works fine. However in Outlook 2007/2010, the table I have always goes to the top right rather than being centered like I have it in my code. Here is my code

    < !DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "">
    <html xmlns:v=”urn:schemas-microsoft-com:vml”>

  25. <!–[if gte mso 9]>

    < ![endif]-->

    …this is the overlaying table with an image and text over the bg image…

    <!–[if gte mso 9]>

    < ![endif]-->


    I am referring to the table that has the “test” classs.

  26. Your width and height on the previous parts of the code have width:600px height:400px. Make sure everything matches. Judging by the dimensions of your image the correct width and height in the VML should be width:600px height:400px everywhere in that code.

  27. I can’t get this to work in Outlook 2016 or 2013 for Windows. On a Mac and in older versions it displays perfectly. Any suggestions?

  28. When I forward my newsletter using Outlook 2013, the link to my style sheet gets removed, thus the media queries don’t exist. Is there a way to use VML to make Outlook not do this? I know Outlook doesn’t support @media, but I don’t want it to remove them when forwarding an email.

  29. Jim G,
    I would suggest not forwarding emails from Outlook. Here is a blog about all the problems forwarding can cause:

    There is no way to control what Outlook (or any other program) does when forwarding an email. Instead, you may want to sign up for a professional sending service (like MailChimp or Emma) if you’re doing the sending, or simply sign up for these emails using a different account.

  30. We have been using this for some time. We just got some new laptops and noticed that on machines where the display text is set to 150% it messes up the v:fill so that in outlook it only showes two thirds of the image and text. We have our emails 630px wide for outlook. If you set the default back to 100% and restart the machine it then rendors correctly. The laptops arrived with 150% zoom enabled so how many other people have this on? Any ideas on how to fix this?

  31. Have been using the bulletproof background solution(mso/vml) since the first of the year and it has been working pretty well in most Outlook 2010 – 2016 versions. But recently discovered that the bulletproof background solution does not appear to be working for Outlook 2016 in Office 365 Plus (Outlook 365?). Has anyone had any luck with background images for the Office 365 Plus version of Outlook 2016? In the mso/vml the background width/height is hard-coded but for some reason in this problematic version of Outlook 2016 for Office 365 Plus, it ignores the hard-coded background dimensions and reduces it and the content over the background to about 10% the width of the email. Thanks

  32. Leave a Reply

    Your email address will not be published. Required fields are marked *

    Free Email Goodies

    <!–[if gte mso 9]>

    < ![endif]-->


    <!–[if gte mso 9]>

    < ![endif]-->

    iPad Air iOS 10
    iPad Air iOS 11
    iPad Mini iOS 10
    iPad Mini iOS 11
    iPad Pro (12.9-inch) iOS 10
    iPad Pro (12.9-inch) iOS 11
    iPad Retina iOS 10
    iPad Retina iOS 11
    iPhone X iOS 11
    iPhone 5S iOS 11
    iPhone 6 iOS 10
    iPhone 6 Gmail iOS 10
    iPhone 6+ iOS 10
    iPhone 6+ Gmail iOS 10
    iPhone 7 iOS 10
    iPhone 7 iOS 11
    iPhone 7 Outlook iOS 11
    iPhone 7+ iOS 10
    iPhone 7+ iOS 11
    iPhone 8 iOS 11
    iPhone 8+ iOS 11
    iPhone SE iOS 10
    iPhone SE iOS 11
    Nexus 5 Android 5.1
    Nexus 5X Gmail Android 6
    Pixel Gmail Android 7
    Pixel Outlook Android 7
    Pixel Yahoo Android 7
    Desktop Clients
    Apple Mail 10 OSX 10.10
    Apple Mail 11 OSX 10.11
    Lotus Notes 8 Windows 7
    Lotus Notes 8.5 Windows 7
    Outlook 2003 Windows 7
    Outlook 2007 Windows 7
    Outlook 2010 Windows 7
    Outlook 2010 (120 dpi) Windows 7
    Outlook 2011 OSX 10.8
    Outlook 2013 Windows 7
    Outlook 2016 OSX 10.8
    Outlook 2016 Windows 7
    Outlook 2016 Windows 10
    Outlook 2016 (120 dpi) Windows 10
    Thunderbird Windows 7
    Web Clients
    Google Apps
    Office 365