HTML: Outlook not rendering proper mail

53 views Asked by At

This is my HTML Table code, and I am not getting the expected output in the Outlook desktop app, but it gives me perfect output in the web outlook.

HTML Code Link:

Expected Output I need:

Outlook Web Output is as expected:

Outlook Desktop App Output, NOT Expected:

Can someone make changes to the html code? I want the expected output into the Outlook desktop app.

1

There are 1 answers

0
Chris Falkenstein On

If you want your desired layout to render consistently across the board, including Outlook instances, you must use tables to lay out your design and you must use a limited set of CSS which should be assigned inline. I'm not going to completely re-code your work, but consider the following HTML. Take note that I'm using tables, even nested tables, styles are applied inline. Note that the two tables that are positioned side by side are left and right aligned and have a width of 49%. That's because if you have two tables with a 50% width the second table tends to fall to beneath the first table. This happens because some instances of Outlook will apply a border and/or spacing around a table. Setting a width of 49% gives 'em a little wiggle room.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <!--[if !mso]><!--><meta http-equiv="X-UA-Compatible" content="IE=edge" /><!--<![endif]-->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="color-scheme" content="light dark">
    <meta name="supported-color-schemes" content="light dark">
    <title>SUBJECT_HERE</title>
</head>
<body style="background: #ffffff; height:100% !important; width:100% !important; margin:0; padding:0; ">
<table cellpadding="0" cellspacing="0" border="0" width="100%" role="presentation" style="background:#ffffff; border-spacing:0 !important; border-collapse: collapse;">
    <tr>
        <td style="font-size:0;">&nbsp;</td>
        <td width="600" align="center" bgcolor="#ffffff">
            <table cellpadding="0" cellspacing="0" border="0" width="100%" role="presentation" style="border-spacing:0 !important; border-collapse:collapse;">
                <tr>
                    <td valign="top" align="center" style="padding: 10px 10px 10px 10px;">
                        
                        <!-- table #1 -->
                        <table cellpadding="0" cellspacing="0" align="center" role="presentation" border="1" style="mso-table-lspace:0pt; mso-table-rspace:0pt; border-spacing:0 !important; border-collapse:collapse;">
                 <tr>
                    <td colspan="4" align="center" style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Safety Report - For the Day (FTD)</td>
                 </tr>
                 <tr>
                    <th style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Verticals</th>
                    <th style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">No. of unsafe situations</th>
                    <th style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">LTI</th>
                    <th style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">First Aid cases</th>
                 </tr>
                 <tr>
                    <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Steel</td>
                    <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 1</td>
                    <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 1</td>
                    <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 1</td>
                 </tr>
                 <tr>
                    <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Minerals</td>
                    <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 2</td>
                    <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 2</td>
                    <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 2</td>
                 </tr>
              </table>
                    </td>
                </tr>
                <tr>
                    <td valign="top" align="center" style="padding: 0 10px 10px 10px;">
                        
                        <!-- table #2 -->
                        <table cellpadding="0" cellspacing="0" width="49%" align="left" role="presentation" border="1" style="mso-table-lspace:0pt; mso-table-rspace:0pt; border-spacing:0 !important; border-collapse:collapse;">
                     <tr>
                        <td colspan="4" align="center" style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Safety Report - For the Day (FTD)</td>
                     </tr>
                     <tr>
                        <th style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Verticals</th>
                        <th style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">No. of unsafe situations</th>
                        <th style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">LTI</th>
                        <th style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">First Aid cases</th>
                     </tr>
                     <tr>
                        <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Steel</td>
                        <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 1</td>
                        <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 1</td>
                        <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 1</td>
                     </tr>
                     <tr>
                        <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Minerals</td>
                        <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 2</td>
                        <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 2</td>
                        <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 2</td>
                     </tr>
                </table>

              <!-- table #2 -->
                    <table cellpadding="0" cellspacing="0" width="49%" align="right" role="presentation" border="1" style="mso-table-lspace:0pt; mso-table-rspace:0pt; border-spacing:0 !important; border-collapse:collapse;">
                        <tr>
                          <td colspan="4" align="center" style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Safety Report - For the Day (FTD)</td>
                        </tr>
                        <tr>
                          <th style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Verticals</th>
                          <th style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">No. of unsafe situations</th>
                          <th style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">LTI</th>
                          <th style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">First Aid cases</th>
                        </tr>
                        <tr>
                          <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Steel</td>
                          <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 1</td>
                          <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 1</td>
                          <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 1</td>
                        </tr>
                        <tr>
                          <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Minerals</td>
                          <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 2</td>
                          <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 2</td>
                          <td style="padding: 5px 5px 5px 5px; font-family: Arial, sans-serif; font-size: 14px; line-height: 18px; color: #000000;">Row 2</td>
                        </tr>
            </table>

                    </td>
                </tr>

            </table>
        </td>
        <td style="font-size:0;">&nbsp;</td>
    </tr>
</table>
</body>
</html>

This is a simple HTML example aimed at answering your specific concern regarding the layout. There's more to address such as responsive design and adapting to light/dark mode but this should get you out of the woods.