I am working on an E-Mail-template and have some issues due to special needs coding for Outlook E-Mails.
In the following I will show an example of a picture with what I tried to make some spacing on top of it.
But several options didn't work out.
However I tried different options like:
<!--[if gte mso 9]>
<img src="img/btn_rng-ans.png" width="180" class="img-btn" style="Margin-top: -20px;">
<![endif]-->
Or
<!--[if gte mso 9]>
<img src="img/btn_rng-ans.png" width="180" class="img-btn" style="margin-top: -20px;">
<![endif]-->
Or
<!--[if gte mso 9]>
<img src="img/btn_rng-ans.png" width="180" class="img-btn" style="padding-top: -20px;">
<![endif]-->
Or
<style>
.rebtn {padding-top: -20px;}
</style>
<!--[if gte mso 9]>
<img src="img/btn_rng-ans.png" width="180" class="img-btn" class="rebtn">
<![endif]-->
Or
<style>
.rebtn {margin-top: -20px;}
</style>
<!--[if gte mso 9]>
<img src="img/btn_rng-ans.png" width="180" class="img-btn" class="rebtn">
<![endif]-->
None of them worked.
I would be very grateful if you could help me with this issue.
Cheers, JD
-------------------EDIT-------------------
So here is some more detail for better understanding:
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:20px">
<tr>
<td align="right">
<a href="#rg">
<!--[if !mso]><!-- -->
<img src="img/btn_rng-ans.png" class="img-btn">
<!--<![endif]-->
<!--[if gte mso 9]>
<img src="img/btn_rng-ans.png" width="180" class="img-btn">
<![endif]-->
</a>
</td>
</tr>
...
</table>
And here the external CSS Code for the image:
.img-btn {width:200px; margin-top: -40px !important;}
It should look like that:
But on Outlook on Windows its like that:
Outlook listens to spacing on block-level elements like <p> and <td>.
You can use a paragraph to create spacing in the following way, noting padding will be ignored:
<p style="margin:20px 0 0 0; line-height:0; font-size:0;"> </p>
Note I'm zeroing the height of the text with line-height and font-size, so that that does not get in the way (would be added to the height of the margin otherwise).
You could also just use the table if you have it already in place:
<td style="padding:20px 0 0 0;">
Outlook doesn't regard margin in a td. You have to use padding. No need to put it in the table as well.
Negative margins are only used when you want to overlap items, and you need a hack for that. But it appears that's a completely different question. What you need to figure out is what is causing the space.
Space in summary can be caused by:
Padding on td, table
Margin on p
Line-height and font-size, even on 'empty' table cells (e.g. <td></td>)
And remember to zero the cellpadding and cellspacing on tables: <table cellspacing="0" cellpadding="0"> unless you are specifically using it
Outlook ignores spacing on:
divs (except for inline-level styles such as font-size)
spans (except for inline-level styles)
attempts at changing elements to block (through display:block), and any padding/margins on that (e.g. trying to do a button on an <a> element)
I just made the following to fix it:
<!--[if !mso]><!-- -->
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:20px">
<tr>
<td align="right">
<a href="#rg">
<img src="img/btn_rng-ans.png" class="img-btn">
</a>
</td>
</tr>
<!--<![endif]-->
<!--[if gte mso 9]>
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:-20px">
<tr>
<td align="right">
<a href="#rg">
<img src="img/btn_rng-ans.png" width="180" class="img-btn">
</a>
</td>
</tr>
</table>
<![endif]-->
Instead of:
<table width="100%" cellpadding="0" cellspacing="0" border="0" style="margin-top:20px">
<tr>
<td align="right">
<a href="#rg">
<!--[if !mso]><!-- -->
<img src="img/btn_rng-ans.png" class="img-btn">
<!--<![endif]-->
<!--[if gte mso 9]>
<img src="img/btn_rng-ans.png" width="180" class="img-btn">
<![endif]-->
</a>
</td>
</tr>
Related
I'm making email template and need to place text in center of the image. I've tried this solution (Table align RIGHT within VML textbox???), but my image can't be displayed.
Here is my code:
<div align="center" style="margin: 0; padding: 0;">
<table border="0" cellspacing="0" cellpadding="0" width="80%" style="width:45em;padding:0;margin:0;border-spacing:0;">
<tbody>
<tr>
<td valign="bottom" height="300" background="https://parentingwalkthrough.com/wp-content/uploads/2018/12/EmailHeader_Image.jpg" style="background-size: 100% 100%;height:15em;text-align: center;">
<!--[if gte mso 9]>
<v:image xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style=" border: 0;display: inline-block; width: 700px; height: 250px;" src="https://parentingwalkthrough.com/wp-content/uploads/2018/12/EmailHeader_Image.jpg" />
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style=" border: 0;display: inline-block;position: absolute; width: 700px; height: 230px;">
<v:fill opacity="0%" color="#111111" />
<v:textbox inset="250px,180px,0px,0px" style="mso-text-scale: 26px; mso-fit-text-to-shape: false; ">
<![endif]-->
<div align="right">
<h1 style="color: #fff; text-transform: uppercase; font-size: 2em;margin-bottom: 1em;">|||Some text in caption here|||</h1>
</div>
<!--[if gte mso 9]>
</v:textbox>
</v:fill>
</v:rect>
</v:image>
<![endif]-->
</td>
</tr>
</tbody>
</table>
It displays good for some certain Outlook window size, but how can i fix the text horizontaly in the center???
If we talk about horizontal center then you need to put table with centered cell inside <v:textbox> tag. Like this:
<!--[if gte mso 9]><v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false"><v:fill type="tile" src="/path/to/image" color="#343434" /><v:textbox style="mso-fit-shape-to-text:true" inset="0,0,0,0"><![endif]-->
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="800" align="center" style="text-align: center;">Centered text</td>
</tr>
</table>
<!--[if gte mso 9]></v:textbox></v:rect><![endif]-->
The background property is not supported in Outlook as it is hown in the markup (only when there is a URL):
<td valign="bottom" height="300" background="https://parentingwalkthrough.com/wp-content/uploads/2018/12/EmailHeader_Image.jpg" style="background-size: 100% 100%;height:15em;text-align: center;">
You can specify a background color, but not an image URL.
The fact is that Outlook uses Word for rendering message bodies. You can read about supported and unsupported HTML elements, attributes, and cascading style sheets properties in the following articles:
Word 2007 HTML and CSS Rendering Capabilities in Outlook 2007 (Part 1 of 2)
Word 2007 HTML and CSS Rendering Capabilities in Outlook 2007 (Part 2 of 2)
I'm currently trying to build an if / else for my html email layout to include different table tags. This is what I'm trying:
<!--[if mso]>
<table class="content-table" role="presentation" cellpadding="0" cellspacing="45" align="center" border="0">
<![endif]-->
<!--[if !mso]> <!---->
<table class="content-table" role="presentation" cellpadding="0" cellspacing="0" align="center" border="0">
<!-- <![endif]-->
</table>
So I'm trying to start my table with a different beginn tag if the mail is opened in outlook. But this is not working. Whats wrong?
This is not a duplicate!
This is an example of how you show and hide in Outlook. If you're viewing this in Outlook, you'll see the word "Outlook". If you view it in a modern email client, you see the words "Modern Email".
https://jsfiddle.net/wallyglenn/5hruzos5/1/
<table>
<tr>
<td>
<!--[if !mso]><!-- -->
<img src="http://via.placeholder.com/300x300/0000ff/?text=Modern+Email" alt="Modern+Email" width="100%" style="display:inline-block;border:none;outline:none;padding:0;margin:0;width:100%;height:auto;" border="0" hspace="0" vspace="0">
<!--<![endif]-->
<!--[if gte mso 9]>
<img src="http://via.placeholder.com/300x300/ff0000?text=Outlook" alt="" width="100%" style="display:inline-block;border:none;outline:none;padding:0;margin:0;width:100%;height:auto;" border="0" hspace="0" vspace="0">
<![endif]-->
</td>
</tr>
</table>
Good luck.
My email build is using the well-known bulletproof background images that campaign monitor have kindly created. This ensures that these images render on various versions of outlook.
Although I'm using the correct HTML & VML code supplied, once testing my email it still does not render the background images on outlook.
I'm currently at my wit's end with this, the code looks perfect.
If there's something that doesn't look right please let me know.
<td background="https://image.ibb.co/dp5R4p/herobg.png" bgcolor="#7bceeb" width="640" valign="top">
<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:640px;">
<v:fill type="tile" src="https://image.ibb.co/dp5R4p/herobg.png" color="#7bceeb" />
<v:textbox style="mso-fit-shape-to-text:true" inset="0,0,0,0">
<![endif]-->
<div>
<table width="640" border="0" cellspacing="0" cellpadding="0" class="MainTable" style="width:640px; margin:0 auto;" align="center">
<tbody>
<tr>
<td style="padding:0px 0px 0px 0px;" class="padding-top-10" align="center">
<img src="https://image.ibb.co/dvzyue/herocta.png" alt="hero offer" width="600" class="width-100" style="width:600px;" border="0">
</td>
</tr>
</tbody>
</table>
</div>
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]-->
</td>
You've removed the height from the original code. I'm guessing that was for responsiveness, but the VML will only show up on Outlook Desktop, so it doesn't need to be responsive. Outlook needs the height to hold the shape open.
I'm looking for a solution where I can add padding to the 'h1' tag. The markup below allows me to render the background image in outlook. However by doing so when I add padding to the td, padding is added to the background - which is not the result I want. Does anyone know how I could add padding to the h1 that is compatible with outlook email clients?
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title></title>
</head>
<body>
<table class="emailwrap" style="background-color:#fff;" cellpadding="0" cellspacing="0" width="100%" align="center">
<tr>
<td style="padding-left:35px;" class="mbl-pad-1" background="images/banner1.jpg" bgcolor="#7bceeb" width="600" height="248" valign="middle" >
<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:600px;height:248px;">
<v:fill type="tile" src="images/banner1.jpg" color="#7bceeb" />
<v:textbox inset="0,0,0,0">
<![endif]-->
<h1 class="emailh1" style="font-size:65px; line-height:60px; font-family:Arial, sans-serif; color:#fff; text-align:left; margin:0;">DO YOU TRUST<br/>YOUR SOURCE?</h1>
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]-->
</td>
</tr>
</table>
</body>
</html>
Nest a new table inside at 100% width and add padding to that td.
So basically:
<td with background >
<table width="100%">
<tr>
<td style="padding: Xpx;">your content</td>
</tr>
</table>
</td>
After a bunch of finagling and the help of user Gortonington I was able to find a solution.By using the markup of found here Bullet Proof Background I was able to get the background image to display correctly in outlook. To add padding to the h1 tag I used the advice of Gortonigton and added an extra table with a width of 100% then added a padding style to the to align the text properly. Thanks for everyone for the help!
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td background="images/banner1.jpg" bgcolor="#333" width="100%" valign="top">
<!--[if gte mso 9]>
<v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:600px;height:248px;">
<v:fill type="tile" src="images/banner1.jpg" color="#333" />
<v:textbox inset="0,0,0,0">
<![endif]-->
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td class="mbl-pad-1" style="padding-left:35px; padding-top:60px; padding-bottom:60px;">
<h1 class="emailh1" style="font-size:65px; line-height:60px; font-family:Arial, sans-serif; color:#fff; text-align:left; margin-top:0; margin-bottom:0;">DO YOU TRUST<br/>YOUR SOURCE?</h1>
</td>
</tr>
</table>
<!--[if gte mso 9]>
</v:textbox>
</v:rect>
<![endif]-->
</td>
</tr>
</table>
Add the margin-left:35px; for H1 tag
<td>
<h1 style="margin-left:35px;"></h1>
</td>
I would add a <div> tag around the <h1> inside <td> and add the padding to it.
<td>
<div style="padding: 10px;">
<h1>...</h1>
</div>
</td>
//EDIT:
If this is only for email, I would just use tables to space it like so:
<td>
<table>
<tr><td colspan="3" height="10"></td></tr>
<tr>
<td width="10"></td>
<td><h1>...</h1></td>
<td width="10"></td>
</tr>
<tr><td colspan="3" height="10"></td></tr>
</table>
</td>
I have a responsive email that i am struggling to make Outlook look correct.
I have the below html which should put the 2 tables next to each other but it is stacking them ontop of each other.
I am using...
<!--[if (gte mso 9)|(IE)]>
to target outlook but it seems to be ignoring this. It is also ignoring my max width call in the style tag.
Any idea why this is happening?
<tr>
<td class="innerpadding ">
<!--[if (gte mso 9)|(IE)]>
<table width="360" align="left" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<![endif]-->
<table class="col400" align="left" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
<tr>
<td>
<img src="Dog.png" alt="Dog Image" width="95%" border="0" style="width:95%;max-width:360px;"/>
</td>
</tr>
</table>
<!--[if (gte mso 9)|(IE)]>
</td>
</tr>
</table>
<![endif]-->
<!--[if (gte mso 9)|(IE)]>
<table width="240" align="right" cellpadding="0" cellspacing="0" border="0">
<tr>
<td>
<![endif]-->
<table class="col240" align="left" border="0" cellpadding="0" cellspacing="0" style="width:100%;">
<tr>
<td>
<span style="font-family:Arial, Helvetica, sans-serif;font-size:38px;color:#f4911c;">Text Here</span>
<span style="font-family:Arial, Helvetica, sans-serif;font-size:16px;color:#555557;display: block;font-style: italic;padding-top: 10px;line-height: 22px;">Text Here</span>
</td>
</tr>
</table>
<!--[if (gte mso 9)|(IE)]>
</td>
</tr>
</table>
<![endif]-->
</td>
</tr>
Try setting a width="" value on your container table. Also adding align="left" there might help. In the past I've found that Outlook has needed that even though it is the children elements that are aligning/floating.
If that doesn't work, just for testing, try adding a top padding and different bgcolor to your conditionally hidden tables to see if they are triggering or not. This will help diagnose if it is the conditional breaking or something else...
Both your tables are set to a width of 100%, try setting the style='width:100%' to 50% for each table and see if this works.
Also, what code is on the classes (col400 and col240) for both tables? This is likely to have an impact.