Sub topic 9
Responsive images and handling blocked images
This chapter assumes you can write the table-based layout and inline CSS from the earlier chapters. It also assumes you know the max-width fluid pattern. Here you will make images scale with the layout, and make the message still read when images do not load.
Why images are a risk in email
Email clients treat images differently from browsers.
- Many clients block remote images until the reader allows them. This is common in corporate Outlook setups and some privacy-focused clients.
- Some clients proxy and cache images (Gmail does this), which can delay loading.
- Desktop Outlook, which renders with the Word engine, ignores several CSS properties on images, including
max-width. - Readers on mobile data may not load large files at all.
Treat every image as optional. The email should still make sense, and the main call to action should still work, with every image missing.
Making an image scale
An image scales fluidly when its container has a flexible width and the image fills it. This is the safest pattern:
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td align="center" bgcolor="#dfe8ff">
<img src="https://example.com/img/hero-1200.jpg"
width="600" height="300"
alt="Spring sale: 20% off all jackets"
style="display:block;width:100%;max-width:600px;height:auto;border:0;outline:none;text-decoration:none;-ms-interpolation-mode:bicubic;font-family:Arial,Helvetica,sans-serif;font-size:20px;line-height:26px;color:#222222;">
</td>
</tr>
</table>Each part of the style attribute and each attribute has a job:
| Setting | Purpose |
|---|---|
| `width="600"` attribute | Gives Outlook a size to use. Outlook ignores `max-width` on images. |
| `height="300"` attribute | Reserves space while the image loads or is blocked. |
| `width:100%` | Lets the image shrink with its container. |
| `max-width:600px` | Stops the image growing past its natural display size in clients that support it. |
| `height:auto` | Keeps the aspect ratio when the width changes. |
| `display:block` | Removes the extra gap under inline images. |
| `border:0` | Removes the blue border some clients add to linked images. |
| `-ms-interpolation-mode:bicubic` | Smoother scaling in old Outlook and IE-based clients. |
The attribute values and the CSS values must agree. If the attribute says 600 and the CSS caps at 600, Outlook and everyone else show the same size.
Sizing for sharp screens
Phones usually have 2x or 3x pixel density. If you display an image at 600 CSS pixels wide, export it at 1200 pixels wide. Set width="600" and the CSS to 600 as above. Without this, the image looks soft on high-density screens.
Keep file size in check, because a 1200-pixel-wide image costs more data:
- Use JPEG for photos at moderate quality (roughly 70 to 80).
- Use PNG for flat graphics, logos, and anything needing transparency.
- Use GIF for animation. Desktop Outlook versions that use the Word engine show only the first frame, so make the first frame carry the message.
- Avoid WebP and SVG in email. Support is uneven across clients.
Aim for a total image weight of a few hundred kilobytes per message.
The `height:auto` trap
When you set height="300" as an attribute and also height:auto in CSS, clients that support CSS use the auto height, which keeps the ratio. Outlook ignores the CSS and uses the attribute, which is correct as long as the attribute matches the displayed width. If you shrink an image in the attribute, recompute both numbers:
<img src="https://example.com/img/logo-320.png"
width="160" height="40"
alt="Northwind"
style="display:block;width:160px;height:auto;border:0;">Here the file is 320 pixels wide and is displayed at 160. Setting only one of the two attributes is a common error. Outlook can then distort the image.
Full-width images in a hybrid layout
In the hybrid pattern from the previous chapters, an image inside a column should use the column width. A two-column row stacks on phones, so each image then needs to fill the full row:
<style>
@media screen and (max-width: 600px) {
.stack { display: block !important; width: 100% !important; }
.fluid-img { width: 100% !important; max-width: 100% !important; height: auto !important; }
}
</style>
<table role="presentation" width="100%" cellpadding="0" cellspacing="0" border="0">
<tr>
<td class="stack" width="50%" valign="top" style="padding:12px;">
<img class="fluid-img" src="https://example.com/img/product-a-600.jpg"
width="270" height="270"
alt="Waterproof jacket in navy"
style="display:block;width:100%;max-width:270px;height:auto;border:0;">
</td>
<td class="stack" width="50%" valign="top" style="padding:12px;">
<img class="fluid-img" src="https://example.com/img/product-b-600.jpg"
width="270" height="270"
alt="Wool scarf in grey"
style="display:block;width:100%;max-width:270px;height:auto;border:0;">
</td>
</tr>
</table>The !important flags are needed because the inline styles would otherwise win over the style block. Clients that drop the style block, such as some Gmail account types, still show a usable two-column layout with scaled images.
Handling blocked images
When images are blocked, the reader sees the alt text, an empty box, or a broken-image icon. You can control much of this.
Write useful alt text
Alt text for a content image should say what the image communicates, not describe it. For the hero above, "Spring sale: 20% off all jackets" works. "Image of woman in coat" does not. For a purely decorative image, use alt="" so screen readers skip it. Do not omit the attribute, because some clients then show the file name or URL.
Style the alt text
Alt text takes its font from the img element in many clients, so set the font on the image itself, as in the first example. You can set font-family, font-size, line-height, and color. Support differs, so treat styled alt text as an enhancement. In Gmail, for example, styled alt text appears but may not honor all properties.
Give the cell a background color
Add bgcolor and a matching background-color to the cell that holds the image. A blocked hero then shows a colored block with readable alt text instead of a hole. Choose a background that gives enough contrast with the alt text color.
Keep key content as live text
Never put the offer, date, price, or the only call to action inside an image. Use real text and a bulletproof button (covered in the previous chapter) for anything the reader must act on. An email made of one large sliced image is a common cause of both spam filtering and an empty-looking message when images are off.
Reserve space and avoid layout jumps
The width and height attributes let the client reserve space. If they are missing, a blocked image can collapse to zero height, and the layout shifts when the reader allows images. Keep the attributes on every image, including tiny spacer and logo images.
Linked images
Wrap a linked image in an <a> and remove the border:
<a href="https://example.com/sale" style="text-decoration:none;">
<img src="https://example.com/img/hero-1200.jpg" width="600" height="300"
alt="Spring sale: 20% off all jackets"
style="display:block;width:100%;max-width:600px;height:auto;border:0;">
</a>Make sure the alt text names the destination or action. Screen readers announce the alt text as the link name.
Common problems and fixes
| Symptom | Likely cause | Fix |
|---|---|---|
| Image is huge in desktop Outlook | No `width` attribute, so Outlook uses the file's pixel size | Add `width` and `height` attributes |
| Small gap under the image | Image is inline and sits on the text baseline | Add `display:block` |
| Image is blurry on phones | File exported at 1x | Export at 2x the display width |
| Image stretches or squashes | Only one dimension forced, or the attribute does not match the ratio | Set both attributes to the same ratio, with `height:auto` in CSS |
| Blue border around linked image | Client default link border | Add `border:0` |
| Empty hole with images off | No background color, alt text, or reserved size | Add `bgcolor`, styled alt text, and dimensions |
| Animation is missing in Outlook | Word engine shows the first frame only | Put the key message in frame one |
Checking your work
Test every template with images disabled. Most clients have a setting for this, and some testing tools offer an images-off preview. Check three things: the text is readable, the main button works, and the layout does not collapse. Then test with images on, on a narrow viewport, and in desktop Outlook.
Exercise
A 600-pixel-wide hero image looks blurry on a phone, and in desktop Outlook it appears much larger than the email layout. Name the changes you would make to the image file and the img tag to fix both problems.
Show answer
For the blur, re-export the file at 1200 pixels wide (2x) while keeping the display size at 600 CSS pixels. For Outlook, add width="600" and a matching height attribute, because Outlook ignores max-width. Keep style="display:block;width:100%;max-width:600px;height:auto;border:0;" so other clients scale the image fluidly.
Exercise
The hero image is the only place the text "Free shipping until Friday" appears. What is wrong with this, and how would you change the email so it survives blocked images?
Show answer
If images are blocked, the reader never sees the offer. Put "Free shipping until Friday" in live text near the image, or in the cell's text. Also write alt text that repeats the offer, style the alt text, and give the cell a background color so the area is readable with images off.