How to set a email head with background image? - html

I am struggling with this piece of code. I have created this header which basically consist of a table with 2 rows and this what am trying to do:
The shadow (bottom part of cid:img-headerbg) has to be at the bottom (how to change cid:img-headerbg to apply on table?)
How to remove this gap, so that yellow line is at bottom?
This is my header:
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="100%" style="background-color: {{accent_color}};">
<tr>
<td background="cid:img-headerbg" bgcolor="{{accent_color}}" valign="bottom" style="background-color:{{accent_color}};background-image: url('cid:img-headerbg');background-size:100% 100%; background-repeat:repeat-x; background-position: top left;">
<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="mso-width-percent:1000;">
<v:fill type="frame" size="100%,100%" src="cid:img-headerbg" color="#eb847b" />
<v:textbox style="mso-fit-shape-to-text:true" inset="0,0,0,0">
<![endif]-->
<div style="max-width: 680px; margin: 0 auto;">
<!--[if mso]>
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="680" align="center">
<tr>
<td>
<![endif]-->
<table style="border:0;border-collapse:collapse;margin:0 auto;padding:0" align="center" border="0" cellpadding="0" cellspacing="0">
<tr>
<td height="30">
</td>
</tr>
<tr>
<td style="margin:0 auto;padding:0;text-align:center;" align="center" width="100%">
<a href="{{base_url}}" style="display: block; top: 0; outline: medium none; text-align: center; text-decoration: none; margin:0 auto;" align="center">
<img alt="{{company_name}}" label="{{company_name}}" src="cid:img-logo" style="border: 0px; display: block; max-width: 100%; max-height: 100%; margin:0 auto;" />
</a>
</td>
</tr>
<tr>
<td style="color:#ffffff;font-family:'Roboto','Open Sans','Helvetica Neue',Helvetica,Arial,sans-serif;font-size:20px;font-weight:400;line-height:25px;margin:0 auto;padding:15px 0;text-align:center;text-decoration:none" align="center" width="100%">
{{header_title}}<br />
<small>{{header_subtitle}}</small>
</td>
</tr>
</table>
<!--[if mso]>
</td>
</tr>
</table>
<![endif]-->
</div>
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]-->
</td>
</tr>
<tr>
<td background="cid:img-colour_stripe" bgcolor="{{primary_color}}" valign="bottom" style="background-color:{{primary_color}};background-image: url('cid:img-colour_stripe');background-size:100% 2px;background-repeat:repeat-x; background-position: bottom left;">
<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="mso-width-percent:1000;">
<v:fill type="frame" size="100%,2px" style="background-size:100% 2px;background-repeat:repeat-x; background-position: bottom left;" src="cid:img-colour_stripe" color="#eb847b" />
<v:textbox style="mso-fit-shape-to-text:true" inset="0,0,0,0">
<![endif]-->
<div style="max-width: 680px; margin: 0 auto;background-color: #ffffff;">
<!--[if mso]>
<table role="presentation" cellspacing="0" cellpadding="0" border="0" width="680" align="center" bgcolor="#ffffff" style="margin: 0 auto;padding:0;">
<tr>
<td>
<![endif]-->
<table cellspacing="0" cellpadding="0" border="0" width="100%" style="margin: 0 auto;">
<tr>
<td height="100%" valign="top" width="100%" style="padding: 10px 0; background-color: #ffffff;margin:0;"></td>
</tr>
</table>
<!--[if mso]>
</td>
</tr>
</table>
<![endif]-->
</div>
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]-->
</td>
</tr>
</table>

Gladly due to some research on my own i found the fix which worked fine for me:
Outlook apparently add empty paragraphs after vml shapes, which was causing the gap. I fix this by adding font-size: 0 and line-height: 0 to the parent container.
https://litmus.com/community/discussions/538-vml-outlook-07-10-13-unwanted-20px-padding-at-the-bottom

Related

Background image not displaying in the outlook using HTML emailer

I am trying to show the background image in Outlook using HTML emailer but it's not showing. I am getting only a blue box. I am using the below code but it's not working.
<table class="container" role="presentation" cellpadding="0" cellspacing="0" border="0" width="600">
<tr>
<td>
<!--[if gte mso 9]>
<v:rect xmlns_v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:600px; background-color:#B5CFE3;height:431px;">
<v:fill type="frame" src="https://i0.wp.com/techacute.com/wp-content/uploads/2019/10/how-to-find-royalty-free-images-on-google-1.png" />
<v:textbox style="mso-fit-shape-to-text:true" inset="0,0,0,0">
<![endif]-->
<div>
<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td style="background: url(https://i0.wp.com/techacute.com/wp-content/uploads/2019/10/how-to-find-royalty-free-images-on-google-1.png) #B5CFE3; background-size:cover; background-position:center;" height="430" width="750">
<!--add your content here-->
</td>
</tr>
</table>
</div>
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]-->
</td>
</tr>
</table>
Couple of issues here.
First, if you had it right, the content inside the VML would show on top. So the td with the background image for non-Outlooks would show again - but just the background colour. So we put that outside the VML.
Second, the background image should be on a <v:image ... />.
Working solution:
<table class="container" role="presentation" cellpadding="0" cellspacing="0" border="0" width="600">
<tr>
<td style="background: url(https://i0.wp.com/techacute.com/wp-content/uploads/2019/10/how-to-find-royalty-free-images-on-google-1.png) #B5CFE3; background-size:cover; background-position:center;" height="430" width="750">
<!--[if gte mso 9]>
<v:image xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style=" border: 0;display: inline-block; width: 450pt; height: 150pt;" src="https://i0.wp.com/techacute.com/wp-content/uploads/2019/10/how-to-find-royalty-free-images-on-google-1.png" />
<v:rect xmlns_v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width: 450pt; height: 150pt;display: inline-block; position: absolute;background-color:#B5CFE3;">
<v:fill type="frame" />
<v:textbox style="mso-fit-shape-to-text:true" inset="0,0,0,0">
<![endif]-->
<div>
<table role="presentation" cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>
<p>content here</p>
</td>
</tr>
</table>
</div>
<!--[if gte mso 9]>
</v:textbox></v:fill></v:rect></v:image>
<![endif]-->
</td>
</tr>
</table>
You'll see I also used points instead of pixels. Outlook tends to work better that way, particularly if using text zoom. (Multiply the pixel value by 0.75 to get points)

Email Design: Text over background image

Am am trying to create a header for an email that has a background image and text centered over it. This is how it looks in "normal" email clients:
However in outlook it doesn't quit work, it ends up like this:
Are there any email gurus that can help me fix this?
Here is what I have so far (built in react):
<table width="640" cellPadding="0" cellSpacing="0" align="center" style={{ margin: '0 auto' }}>
<tbody>
<tr>
<td
height="143"
width="640"
align="center"
valign="middle"
background="https://image.shutterstock.com/image-illustration/website-header-banner-design-abstract-260nw-1621024345.jpg"
style={{ backgroundColor: '#00A699', backgroundSize: 'cover' }}
>
<div
dangerouslySetInnerHTML={{
__html: `<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:640px;height:143px">
<v:fill type="frame" src="https://image.shutterstock.com/image-illustration/website-header-banner-design-abstract-260nw-1621024345.jpg" />
<v:textbox inset="0,0,0,0" style="v-text-anchor:middle">
<![endif]-->`,
}}
/>
<table
cellPadding="0"
cellSpacing="0"
className="arb_w100 "
align="center"
style={{ margin: '0 auto' }}
>
<tbody>
<tr>
<td align="center">
<td
align="center"
valign="bottom"
className="arb_headline_1"
style={{ paddingTop: '10px' }}
>
<span
style={{
fontSize: '22px',
fontWeight: 400,
fontFamily: 'Helvetica, Arial, sans-serif',
lineHeight: '28px',
color: '#ffffff',
}}
>
For a limited time, take
</span>
</td>
</td>
</tr>
</tbody>
</table>
<div
dangerouslySetInnerHTML={{
__html: `<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]-->`,
}}
/>
</td>
</tr>
</tbody>
</table>
Below is the code from above translated to standard HTML:
<table width="640" cellPadding="0" cellSpacing="0" align="center" style="margin:0 auto">
<tbody>
<tr>
<td height="143" width="640" align="center" valign="middle"
background="https://image.shutterstock.com/image-illustration/website-header-banner-design-abstract-260nw-1621024345.jpg"
style="background-color:#00A699;background-size:cover">
<div><!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:640px;height:143px">
<v:fill type="frame" src="https://image.shutterstock.com/image-illustration/website-header-banner-design-abstract-260nw-1621024345.jpg" />
<v:textbox inset="0,0,0,0" style="v-text-anchor:middle">
<![endif]--></div>
<table cellPadding="0" cellSpacing="0" className="arb_w100 " align="center" style="margin:0 auto">
<tbody>
<tr>
<td align="center">
<td align="center" valign="bottom" className="arb_headline_1" style="padding-top: 10px;"><span
style="font-size: 22px; font-weight: 400; font-family: Helvetica, Arial, sans-serif; line-height: 28px; color: rgb(255, 255, 255);">For a limited time, take</span>
</td>
</td>
</tr>
</tbody>
</table>
<div><!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]--></div>
</td>
</tr>
</tbody>
</table>
Thanks for supplying the final HTML, that helped a lot!
So you've got a couple of issues with your final HTML.
You have divs wrapping each of the MSO snippets which essentially closes off and breaks the snippets. So remove the closing div tag for the first MSO snippet and the opening div tag for the second snippet.
You'll need need to shift these two tags in, so it is only wrapping your inner content. We usually add a div to wrap the inner content to help reset the HTML in Outlook and then we can set whatever styles etc in the inner content.
I then noticed you've got a double up of the inner tags. Remove the outer tags as they don't have any styles declared, whereas the inner one does.
Amending those small things will fix your issue.
Here is the snippet cleaned up in case my instructions don't make sense:
<table width="640" cellPadding="0" cellSpacing="0" align="center" style="margin:0 auto">
<tbody>
<tr>
<td height="143" width="640" align="center" background="https://image.shutterstock.com/image-illustration/website-header-banner-design-abstract-260nw-1621024345.jpg" style="background-color:#00A699;background-size:cover">
<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:640px;height:143px">
<v:fill type="frame" src="https://image.shutterstock.com/image-illustration/website-header-banner-design-abstract-260nw-1621024345.jpg" />
<v:textbox inset="0,0,0,0" style="v-text-anchor:middle">
<![endif]-->
<div>
<table cellPadding="0" cellSpacing="0" className="arb_w100 " align="center" style="margin:0 auto">
<tbody>
<tr>
<td align="center" className="arb_headline_1" style="padding-top: 10px;"><span style="font-size: 22px; font-weight: 400; font-family: Helvetica, Arial, sans-serif; line-height: 28px; color: rgb(255, 255, 255);">For a limited time, take</span>
</td>
</tr>
</tbody>
</table>
</div>
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]-->
</td>
</tr>
</tbody>
</table>

Unable to Center Banner in Responsive Layout

I'm trying to get the banner to center as you it sizes down to a smaller resolution as opposed to pushing the image to the right. Here is the page I am referring to. Page
I'm using 100% width.
<!-- BEGIN TEMPLATE HEADING IMAGE - Full 100% Width // -->
<tr class="heading">
<td align="center" valign="top" id="preview" bgcolor="#FFFFFF" style="background-color:#FFFFFF; padding:0px; border-bottom:1px solid #eeeeee;">
<table cellpadding="0" cellspacing="0" border="0" height="400" width="100%">
<tr>
<td background="https://www.acuity-sports.com/newsletter/images/banner10.jpg" bgcolor="#ffffff" width="100%" height="400" valign="top">
<img editable width="600" src="" style="max-width:600; border:0px; display:block;" mc:edit="header_image" />
<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:600px;height:350px;">
<v:fill type="tile" src="images/main_image.jpg" color="#ffffff" />
<v:textbox inset="0,0,0,0">
<![endif]-->
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]-->
</td>
</tr>
</table>
</td>
</tr>
<!-- END TEMPLATE HEADING IMAGE - Full 100% Width // -->
use css properties: background-position for td with your banner
background-position: center;
for your element will make center align.
Also you can do it via style attribute
style="background-position: center;"
try this code
<!-- BEGIN TEMPLATE HEADING IMAGE - Full 100% Width // -->
<tr class="heading">
<td align="center" valign="top" id="preview" bgcolor="#FFFFFF" style="background-color:#FFFFFF; padding:0px; border-bottom:1px solid #eeeeee;">
<table cellpadding="0" cellspacing="0" border="0" height="400" width="100%">
<tr>
<td bgcolor="#ffffff" width="100%" height="400" valign="top">
<img width="100%" src="https://www.acuity-sports.com/newsletter/images/banner10.jpg" style="max-width:600; border:0px; display:block;" mc:edit="header_image" />
<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:600px;height:350px;">
<v:fill type="tile" src="images/main_image.jpg" color="#ffffff" />
<v:textbox inset="0,0,0,0">
<![endif]-->
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]-->
</td>
</tr>
</table>
</td>
</tr>
try this online demo: http://jsfiddle.net/40jhoe0x/1/
thank you

Table align RIGHT within VML textbox???

Does anyone know how to align a table right within a VML textbox? Left and center work fine but Right seems to get ignored....
Heres and example of the code
<table width="600" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td bgcolor="#DDDDDD" style="background-image: url('http://i.imgur.com/XCnBXwP.png');" background="http://i.imgur.com/XCnBXwP.png" height="92" valign="top"><!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:600px;height:92px;">
<v:fill type="tile" src="http://i.imgur.com/XCnBXwP.png" color="#7bceeb" />
<v:textbox inset="0,0,0,0">
<![endif]-->
<div>
<table width="300" border="0" cellpadding="0" cellspacing="0" align="right">
<tr>
<td bgcolor="#FF00FF" align="right" style="font-family:Arial, Helvetica, sans-serif; font-size:20px; font-weight:bold;"> | This is test text | </td>
</tr>
</table>
</div>
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]--></td>
</tr>
</table>
Try setting your <div> to width:100%;. If that doesn't fix it, put a 100% width table in there, nest and align the child (your desired content) within that.
Example:
<table width="600" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td bgcolor="#DDDDDD" style="background-image: url('http://i.imgur.com/XCnBXwP.png');" background="http://i.imgur.com/XCnBXwP.png" height="92" valign="top"><!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:600px;height:92px;">
<v:fill type="tile" src="http://i.imgur.com/XCnBXwP.png" color="#7bceeb" />
<v:textbox inset="0,0,0,0">
<![endif]-->
<div style="width:100%;">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td align="right">
<table width="300" border="0" cellpadding="0" cellspacing="0" align="right">
<tr>
<td bgcolor="#FF00FF" align="right" style="font-family:Arial, Helvetica, sans-serif; font-size:20px; font-weight:bold;"> | This is test text | </td>
</tr>
</table>
</td>
</tr>
</table>
</div>
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]--></td>
</tr>
</table>
Sorry, late coming to the party...
you need an extra div with align="right" before you table & contents. VML textbox ignores align on tables for some reason.
<table width="600" border="0" cellpadding="0" cellspacing="0" align="center">
<tr>
<td bgcolor="#DDDDDD" style="background-image: url('http://i.imgur.com/XCnBXwP.png');" background="http://i.imgur.com/XCnBXwP.png" height="92" valign="top"><!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:600px;height:92px;">
<v:fill type="tile" src="http://i.imgur.com/XCnBXwP.png" color="#7bceeb" />
<v:textbox inset="0,0,0,0">
<![endif]-->
<div>
<div align="right">
<table width="300" border="0" cellpadding="0" cellspacing="0" align="right">
<tr>
<td bgcolor="#FF00FF" align="right" style="font-family:Arial, Helvetica, sans-serif; font-size:20px; font-weight:bold;"> | This is test text | </td>
</tr>
</table>
</div>
</div>
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]-->
</td>
</tr>
</table>
And here is the link

Applying background Image to table cell with VML

I am trying to apply a repeating background to a table cell for an html email, I am using the code from http://backgrounds.cm/
Here is my TD and wrapper VML:
<td background="http://domain.com/Portals/0/emails/images/stripes-middle.png" bgcolor="#00ff00" width="346" valign="top">
<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:346px;">
<v:fill type="tile" src="http://domain.com/Portals/0/emails/images/stripes-middle.png" color="#ff0000" />
<v:textbox style="mso-fit-shape-to-text:true" inset="0,0,0,0">
<![endif]-->
<div>
<p>LOTS OF CONTENT IN HERE</p>
</div>
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]-->
</td>
However, it is renderring my background image up in the top left of the parent table! Not within the table cell. How can I fix this?
why not nest it in another table then?
<table border="0" cellpadding="0" cellspacing="0" width="640" style="border-collapse:collapse; padding:0; margin:0px;">
<tr valign="top">
<td align="center" valign="top">
<table border="0" cellpadding="0" cellspacing="0" width="346" style="border-collapse:collapse; padding:0; margin:0px;">
<tr valign="top">
<td background="http://domain.com/Portals/0/emails/images/stripes-middle.png" bgcolor="#ff0000" width="346" height="112" valign="top">
<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:346px;height:112;">
<v:fill type="tile" src="http://domain.com/Portals/0/emails/images/stripes-middle.png" color="#ff0000" />
<v:textbox inset="0,0,0,0">
<![endif]-->
<div>
<table border="0" cellpadding="0" cellspacing="0" width="346" style="border-collapse:collapse; padding:0; margin:0px;">
<tr valign="top">
<td align="left" valign="top">
<p>LOTS OF CONTENT IN HERE</p>
</td>
</tr>
</table>
</div>
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]-->
</td>
</tr>
</table>
</td>
</tr>
</table>
can't pinpoint exactly where you're going wrong, but I've never used fit-shape-to-text before and this snippet hasn't done me wrong.