Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Formatting html email for Outlook

Tags:

html

css

outlook

I have an html newsletter which works in most email clients, but the formatting is messed up in Outlook.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <style type="text/css">   body {     background-color: #98AFC7;   }  </style> <title></title> </head> <body> <table border="1px solid" cellspacing="0" cellpadding="10px" width="600" style="margin-left: auto; margin-right: auto; height:auto; background-color: #ffffff; margin-top: 60px;">     <tr>         <td align="top" style="padding: 10px; font-family: arial; font-size: 12px;" ><center>Email not displaying correctly?<a href="#"><strong> View it in your browser</strong></a></center></td>     </tr>     <tr>         <td style="border: 1px solid; height: 80px; text-align: center; padding: 10px;"><img src="http://demo.frostmiller.com/email/img/banner.jpg" alt="Banner will go here" align="middle" style="border: 1px solid;"></td>     </tr>     <tr>         <td>             <table style="border: 0; cellspacing: 0; cellpadding: 10px; height: auto;">                 <tr>                     <td valign="baseline" style="padding: 10px; width:400px; border: 1px solid; halign: top;">                     <h3>Top Stories</h3>                          <ul>                             <li>Topic 1</li>                             <li>Topic 2</li>                             <li>Topic 3</li>                         </ul>                             <p>Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>                     </td>                     <td valign="baseline" style="padding: 10px; border: 1px solid;">                         <h3>Latest News</h3>                         <p>                         Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting,                           </p>                     </td>                 </tr>             </table>                         </td>     </tr>     <tr>         <td cellpadding="10px" style="border: 1px solid; cellspacing: 0;  width: 100%; height: auto; text-align: center;">             <strong>Copyright &copy 2011 Frost Miller Group </strong>         </td>     </tr>     <tr>         <td style="border: 1px solid; cellspacing: 0; cellpadding: 10px; width: 100%; height: auto">             <center>             <a href="#">Contact Us</a>             &nbsp;             <a href="#">Terms of Use</a>             &nbsp;             <a href="#">Trademarks</a>             &nbsp;             <a href="#">Privacy Statement</a>             &nbsp;             <a href="#">Site Feedback</a>             </center>         </td>     </tr>     </table> </body> </html> 

What changes do I need to make in order to get it to display correctly in Outlook?

like image 863
user544079 Avatar asked May 02 '11 19:05

user544079


People also ask

How do I edit HTML email in Outlook?

To edit the HTML source code of a message you are composing in Windows Live Mail or Outlook Express. Select View > Source Edit from the message's menu. Click on the Source tab at the bottom of the window. Edit the HTML source as much as you like.

How do I forward an HTML email without losing formatting?

You can apply the following settings to forward the message in HTML format: “Settings” -> “Preferences” tab -> “Composing Messages” -> “Compose HTML messages” -> Select “on forward or reply to HTML message” under “Compose HTML messages” and save.


2 Answers

To be able to give you specific help, you's have to explain what particular parts specifically "get messed up", or perhaps offer a screenshot. It also helps to know what version of Outlook you encounter the problem in.

Either way, CampaignMonitor.com's CSS guide has often helped me out debugging email client inconsistencies.

From that guide you can see several things just won't work well or at all in Outlook, here are some highlights of the more important ones:

  • Various types of more sophisticated selectors, e.g. E:first-child, E:hover, E > F (Child combinator), E + F (Adjacent sibling combinator), E ~ F (General sibling combinator). This unfortunately means resorting to workarounds like inline styles.
  • Some font properties, e.g. white-space won't work.
  • The background-image property won't work.
  • There are several issues with the Box Model properties, most importantly height, width, and the max- versions are either not usable or have bugs for certain elements.
  • Positioning and Display issues (e.g. display, floats and position are all out).

In short: combining CSS and Outlook can be a pain. Be prepared to use many ugly workarounds.

PS. In your specific case, there are two minor issues in your html that may cause you odd behavior. There's "align=top" where you probably meant to use vertical-align. Also: cell-padding for tds doesn't exist.

like image 200
Jeroen Avatar answered Oct 04 '22 06:10

Jeroen


You should definitely check out the MSDN on what Outlook will support in regards to css and html. The link is here: http://msdn.microsoft.com/en-us/library/aa338201(v=office.12).aspx. If you do not have at least office 2007 you really need to upgrade as there are major differences between 2007 and previous editions. Also try saving the resulting email to file and examine it with firefox you will see what is being changed by outlook and possibly have a more specific question to ask. You can use Word to view the email as a sort of preview as well (but you won't get info on what styles are/are not being applied.

like image 22
scrappedcola Avatar answered Oct 04 '22 07:10

scrappedcola