编码HTML电子邮件时需要使用间隔图像吗? [英] Do I need to use spacer images when coding HTML emails?

查看:114
本文介绍了编码HTML电子邮件时需要使用间隔图像吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我明白,HTML电子邮件需要使用真正的旧学校布局,就像SO的许多其他答案一样(例如 HTML电子邮件:表格或divs 使用CSS的HTML电子邮件

I understand that HTML emails need to use really old school layouts - as per lots of other answers on SO (e.g. HTML email: tables or divs?, HTML Email using CSS).

然而,似乎有一些争论在电子邮件中是否使用spacer gif仍然是个好主意。

However, there seems to be some debate over whether it's still a good idea to use spacer gifs in email.

例如,比较这三个布局:

For example, compare these three layouts:

尺寸:

<table cellpadding="0" cellspacing="0" border="0" width="100">
  <tr>
    <td width="100" height="10"></td>
  </tr>
</table>

WITH SPACER GIF:

WITH SPACER GIF:

<table cellpadding="0" cellspacing="0" border="0">
  <tr>
    <td><img src="spacer.gif" width="100" height="10"></td>
  </tr>
</table>

WITH SPACER GIF和DIMENSIONS:

WITH SPACER GIF AND DIMENSIONS:

<table cellpadding="0" cellspacing="0" border="0" width="100">
  <tr>
    <td width="100" height="10"><img src="spacer.gif" width="100" height="10"></td>
  </tr>
</table>

如何使用尺寸?有没有任何电子邮件客户端仍然需要spacer gif?有没有任何伤害?

How do I use them with dimensions? Are there any email clients that still require spacer gifs? Is there any harm done either way?

推荐答案

个人而言,我从不使用spacer gif,因为在图像阻止关闭时它们会破坏布局,原因有三: / p>

Personally, I never use spacer gifs, because they destroy the layout when image blocking is turned off, for three reasons:


  1. 如果它们根本不呈现,则需要使用间隔图像的任何布局都将丢失。

  2. 如果它们呈现不正确(例如恢复到原始大小,或按比例缩小到原始大小),则会破坏布局。

  3. 即使它们正确呈现并且布局正常,所有图像占位符在图像阻止打开时显示分散于电子邮件的消息。

要解决问题#2,您可以保存每个图像的实际尺寸。但是,这显然会增加:

To get around issue #2, you can save each image with its actual dimensions. However, this obviously increases:


  • 建立时间

  • 客户端要下载的图像数量

,它不会解决问题#1和#3。

and it doesn't solve issues #1 and #3.

使用spacer gif的原因是因为某些客户端(Outlook 2007,Outlook 2010,Lotus Notes,Hotmail / Live Mail)不会呈现一个空单元格。对于文本节点的尺寸绝对精确度非常困难,因此间隔图像就足够了。然而,即使是所提到的那些客户端也会呈现一个空格,定义。

The reason for using spacer gifs is because some clients (Outlook 2007, Outlook 2010, Lotus Notes, Hotmail / Live Mail) will not render an empty cell. It's very difficult to have absolute precision over dimensions of a text node, and so a spacer image suffices. However, even those clients mentioned will render an empty cell that has width defined.

所以只要你定义像素宽度空细胞你没事。要回到以下问题中的示例:

So as long as you're defining pixel widths on any empty cells you are fine. To go back to the examples in the question:


  • 仅限维度 - 在所有主要电子邮件客户端中都可以使用和不使用图像阻止
  • Dimensions-only - works with and without image-blocking in all major email clients
  • Spacer images only - works only when image-blocking is turned off
  • Dimensions and spacer images - works only when image-blocking is turned off

因此,您应该使用维度而不是spacer gifs

各种文章还讨论了这个问题(在页面上搜索spacer images)

Various articles talk about this question as well (search for 'spacer images' on the pages)

  • http://www.banane.com/workblog/?p=61
  • http://www.campaignmonitor.com/design-guidelines/

这篇关于编码HTML电子邮件时需要使用间隔图像吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆