htmloutlookbackground-imagehtml-emailvml

How to center align text for background image for OUTLOOK in HTML Email Template?


I am creating Email Template. Where I want and background image for <td>. I have used VML code to make it work on Outlook and its older versions. I have tested my Email Template and it is working fine in Browser and GMAIL but not working in OUTLOOK

I want to achieve the result which is in below screenshot. Which I am getting in Browser and GMAIL but no in OUTLOOK

enter image description here

In Outlook text Your Quertly Update is rendering on top left. I have tried to use position: absolute; top: 50%; left:0 right: 0; but that is also not working

enter image description here

Here is the code below which I am using.

Code:

<table cellpadding="0" cellspacing="0" border="0" width="600" height="100" align="center">
  <tr>


 <td background="https://picsum.photos/600/100" bgcolor="#ffffff" width="530" height="95" valign="middle" style="background-image: url('https://picsum.photos/600/100');background-repeat:no-repeat; text-align:center; vertical-align:middle;">
 
   <!--[if gte mso 9]>
  <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:530px;height:95px;color:#ffffff">
    <v:fill type="tile" src="https://picsum.photos/600/100" color="#ffffff" />
    <v:textbox inset="0,0,0,0">
  <![endif]-->
 
   <p style="font-family:Arial, Helvetica, sans-serif; font-size:40px; color:#ffffff; margin: 0;">Your quarterly Update</p>
  
  <!--[if gte mso 9]>
    </v:textbox>
  </v:rect>
  <![endif]-->
</td>
</tr>
</table>

Is there anything which I need to change in VML code to get my text in center and middle, vertically and horizontally.


Solution

  • Take the contents of the paragraph and place it in a table with padding on the td. Below is the method I use:

    <table cellpadding="0" cellspacing="0" border="0" width="600" height="100" align="center">
      <tr>
    
    
     <td background="https://picsum.photos/600/100" bgcolor="#ffffff" width="530" height="95" style="background-image: url('https://picsum.photos/600/100');background-repeat:no-repeat;vertical-align:top;">
     
       <!--[if gte mso 9]>
      <v:rect xmlns:v="urn:schemas-microsoft-com:vml" fill="true" stroke="false" style="width:530px;height:95px;color:#ffffff">
        <v:fill type="tile" src="https://picsum.photos/600/100" color="#ffffff" />
        <v:textbox inset="0,0,0,0">
      <![endif]-->
     <table cellpadding="0" cellspacing="0" border="0" width="600" height="100" align="center">
      <tr>
       <td style="font-family:Arial, Helvetica, sans-serif; font-size:40px; color:#ffffff;text-align:center;padding-top:20px;">Your quarterly Update</p></td>
      </tr>
    </table>
      <!--[if gte mso 9]>
        </v:textbox>
      </v:rect>
      <![endif]-->
    </td>
    </tr>
    </table>

    Hope this is the answer you were looking for.

    Cheers