Email Marketing & Automation

How To Use High-Resolution Images for Retina Displays In Your HTML Email

Retina display is a marketing term used by Apple to describe a high-resolution display that has a pixel density high enough that the human eye is unable to distinguish individual pixels at a typical viewing distance. A retina display typically has a pixel density of 300 pixels per inch (ppi) or higher, which is significantly higher than a standard display with a pixel density of 72 ppi.

Retina displays are now quite mainstream for displays, laptops, mobile devices, and tablets. Many manufacturers now offer high-resolution displays with pixel densities that match or exceed those of Apple’s Retina displays.

CSS To Display A Higher Resolution Image For A Retina Display

You can use the following CSS code to load a high-resolution image for a Retina display. This code detects the device’s pixel density and loads the image with the @2x suffix for Retina displays, while loading the standard-resolution image for other displays.

@media only screen and (-webkit-min-device-pixel-ratio: 2), only screen and (min--moz-device-pixel-ratio: 2), only screen and (-o-min-device-pixel-ratio: 2/1), only screen and (min-device-pixel-ratio: 2) {
/* Load high-resolution image */
background-image: url('image@2x.png');
}

Another approach is to use vector graphics or SVG images, which can scale to any resolution without losing quality. Here’s an example:

<div style="max-width: 300px;">
    <svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
        <circle cx="50" cy="50" r="40" stroke="black" stroke-width="3" fill="red" />
    </svg>
</div>

In this example, the SVG code is embedded directly in the HTML email using the <svg> tag. The viewBox attribute defines the dimensions of the SVG image, while the xmlns attribute specifies the XML namespace for SVG.

The max-width property is set on the div element to ensure that the SVG image scales automatically to fit the available space, up to a maximum width of 300px in this case. This is a best practice for ensuring that SVG images are displayed properly on all devices and email clients.

Note: SVG support can vary depending on the email client, so it’s important to test your email on multiple clients to ensure that the SVG image is displayed properly.

Another way of coding HTML emails for Retina displays is to utilize srcset. Using the srcset attribute allows you to provide high-resolution images for Retina displays while ensuring that the images are properly sized for lower-resolution devices.

<img src="image@2x.jpg" srcset="image.jpg 600w, image@2x.jpg 1200w" alt="My Image" style="width:100%;max-width:600px;">

In this example, the srcset attribute provides two image sources: image.jpg for devices with a resolution of 600 pixels or less, and image@2x.jpg for devices with a resolution of 1200 pixels or more. The 600w and 1200w descriptors specify the size of the images in pixels, which helps the browser determine which image to download based on the device’s resolution.

Not all email clients support the srcset attribute. The level of support for srcset can vary widely depending on the email client, so it’s important to test your emails on multiple clients to ensure that the images are displayed properly.

HTML For Images In Email Optimized For Retina Displays

it is possible to code a responsive HTML email that will properly display an image at a resolution optimized for retina displays. Here’s how:

  1. Create a high-resolution image that is double the size of the actual image you want to display in the email. For example, if you want to display a 300×200 image, create a 600×400 image.
  2. Save the high-resolution image with the @2x suffix. For example, if your original image is image.png, save the high-resolution version as image@2x.png.
  3. In your HTML email code, use the following code to display the image:
<img src="image.png" alt="Image" width="300" height="200" style="display:block; border:none; outline:none; text-decoration:none; -ms-interpolation-mode:bicubic;">
<!--[if (gte mso 9)|(IE)]>
  <img src="image@2x.png" alt="Image" width="300" height="200" style="display:block; border:none; outline:none; text-decoration:none; -ms-interpolation-mode:bicubic;">
<![endif]-->

<!--[if (gte mso 9)|(IE)]> is a conditional comment that is used to target specific versions of Microsoft Outlook, which uses Microsoft Word to render HTML emails. Microsoft Word’s HTML rendering engine can be quite different from other email clients and web browsers, so it often requires special handling. The (gte mso 9) condition checks if the Microsoft Office version is greater than or equal to 9, which corresponds to Microsoft Office 2000. The |(IE) condition checks if the client is Internet Explorer, which is often used by Microsoft Outlook.

HTML Email With Retina Display Optimized Images

Here’s an example of a responsive HTML email code that displays an image at a resolution optimized for retina displays:

<!doctype html>
<html>
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>My Retina-Optimized Email</title>
  <style>
    /* Mobile-specific styles */
    @media only screen and (max-width: 480px) {
      /* Add mobile-specific styles here */
    }
    
    /* High-density display styles */
    @media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
      img {
        display: block;
        width: 300px !important;
        height: 200px !important;
        max-width: 100%;
        height: auto;
      }
    }
  </style>
</head>
<body style="margin: 0; padding: 0; background-color: #f7f7f7;">
  <table border="0" cellpadding="0" cellspacing="0" width="100%">
    <tr>
      <td align="center" style="padding: 40px 0 30px 0;">
        <img src="image.png" alt="My Image" width="300" height="200" style="display:block; border:none; outline:none; text-decoration:none; -ms-interpolation-mode:bicubic;">
        <!--[if (gte mso 9)|(IE)]>
          <img src="image@2x.png" alt="My Image" width="300" height="200" style="display:block; border:none; outline:none; text-decoration:none; -ms-interpolation-mode:bicubic;">
        <![endif]-->
      </td>
    </tr>
  </table>
</body>
</html>

Retina Display Image Tips

Here are some additional tips on optimizing your HTML Emails for images optimized for Retina displays:

  • Be sure to always have your image tags include using alt text to provide context for the image.
  • Optimize images for the web to reduce file size without compromising image quality. This can include using image compression tools, reducing the number of colors used in the image, and resizing the image to its optimal dimensions before uploading it to the email.
  • Avoid large background images that can slow down email load times.
  • Animated GIFs can be larger in file size than static images due to the multiple frames needed to create the animation, be sure to keep them well under 1 Mb.

Appreciate this content?

Sign up for our weekly newsletter, which delivers our latest posts every Monday morning.

We don’t spam! Read our privacy policy for more info.

Douglas Karr

Douglas Karr is CMO of OpenINSIGHTS and the founder of the Martech Zone. Douglas has helped dozens of successful MarTech startups, has assisted in the due diligence of over $5 bil in Martech acquisitions and investments, and continues to assist companies in implementing and automating their sales and marketing strategies. Douglas is an internationally recognized digital transformation and MarTech expert and speaker. Douglas is also a published author of a Dummie's guide and a business leadership book.
Back to top button
Close

Adblock Detected

Martech Zone is able to provide you this content at no cost because we monetize our site through ad revenue, affiliate links, and sponsorships. We would appreciate if you would remove your ad blocker as you view our site.