As email marketers in the ever-evolving world of digital marketing 🛒💰, ensuring your promotional emails look great on every device is crucial.
Lets have a quick look on how to create SFMC emails that dynamically render for both desktop and mobile views.
The Challenge:
Traditionally, maintaining separate images for desktop and mobile within SFMC emails required manual updates directly in the code, which was time-consuming and prone to errors.
The Solution:
By leveraging CSS media queries and SFMC’s content builder, we can create responsive emails that automatically adjust content based on the viewer’s device.
Here’s a simple example:
----------------------- HTML ---------------------
<!-- Desktop Image -->
<img src="desktop-image.jpg" alt="Desktop Version" style="width:100%; max-width:600px; display:none;" class="desktopImage">
<!-- Mobile Image -->
<img src="mobile-image.jpg" alt="Mobile Version" style="width:100%; max-width:300px; display:block;" class="mobileImage">
----------------------- CSS ------------------------
@media only screen and (min-width: 601px) {
.desktopImage { display: block; }
.mobileImage { display: none; }
}
The Result:
With the above code, the email template will display the desktop image for screens wider than 600px and the mobile image for screens smaller or equal to 600px. This ensures that your audience enjoys a tailored experience, no matter the device.
To further enhance the dynamic nature of your emails, consider using content blocks that can be easily swapped, edited, and reused across different campaigns.
This not only saves time but also maintains consistency in branding.Â
By  Ameen RahmanÂ