Email Not Displaying Correctly in Gmail: Fix Padding & Margin Collapsing for MJML Framework for Retail & Consumer Brand Campaigns
Retail campaigns rely on high-fidelity visual assets, coupon borders, and clear promotional layouts. Default image blocking or button collapses disrupt the visual journey. Below is the targeted integration guide to fix Padding & Margin Collapsing inside Gmail App (iOS & Android) templates when using MJML Framework.
Technical Breakdown
Gmail App (iOS & Android) uses the WebKit / Blink which lacks support for standard rendering rules. This causes Padding & Margin Collapsing elements to break or collapse when rendering templates.
MJML Framework Behaviors
The MJML transpilation compiler parses dynamic columns and wraps them in custom HTML conditional tags. If you paste direct tables or VML code blocks inside an MJML layout without proper escaping, the MJML compiler will try to clean the code, resulting in stripped Outlook namespaces and broken layouts. Always define ALT descriptions for retail product shots, and base64-encode your brand logo so the email headers render cleanly even when images are blocked.
Remediation Code Block
To ensure spacing works reliably, apply all structural paddings directly to HTML td elements inside tables. Do not apply paddings or margins to raw divs, as Outlook will strip them. For vertical spacing, use explicit spacer tables or empty rows. In your MJML Framework campaign manager, make sure you configure your links to run via {{unsubscribe_link}}.
<table role="presentation" border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td height="20" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
<tr>
<td style="padding: 15px; background-color: #f1f1f1;">
Content with padding and margin
</td>
</tr>
<tr>
<td height="20" style="font-size: 1px; line-height: 1px;"> </td>
</tr>
</table>Live Code Sandbox Test
How to Deploy inside MJML Framework
Copy the fixed VML or table wrapper code block from the remediation box above.
Wrap the entire RenderOps corrected table block inside an '<mj-raw>' tag block. This tells the MJML compiler to bypass parsing on this segment, exporting the exact conditional statements into the final HTML output.