创建 HTML 电子邮件时,我们应该使用 html、head、body 标签吗?
在我的电子邮件视图中,我通常只是做类似的事情...
<dl>
<dt>Name</dt>
<dd>Value</dd>
</dl>
我应该这样做吗?
<html>
<head></head>
<body>
<dl>
<dt>Name</dt>
<dd>Value</dd>
</dl>
</body>
</html>
换句话说,就像我在标记一个独立的文档一样?
我想我可以放心地假设任何基于网络的电子邮件客户端都会将其删除?
正确的方法是什么?
In my email views, I usually just do something like...
<dl>
<dt>Name</dt>
<dd>Value</dd>
</dl>
Should I be doing it like this?
<html>
<head></head>
<body>
<dl>
<dt>Name</dt>
<dd>Value</dd>
</dl>
</body>
</html>
In other words, like I was marking up a standalone document?
I guess I can safely assume any web based email client will strip it out?
What is the right way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
正确的方法是遵循 HTML 标准。您可以在此处验证您的 HTML 页面。
您的邮件客户端应该遵循它,并且应该丢弃不支持或不安全的内容,例如 JavaScript。
我将揭示以下标准在这里可能有益的一些原因:
The right way is to follow the HTML standard. You can validate your HTML page here.
Your mail client should follow it and should throw away what's not supported or what's insecure, like JavaScript.
I'll expose some reasons why following standards could be beneficial here:
无论是否包含 html/head/body 标记都完全无关 - 它们始终是可选的,不会以任何方式影响文档的呈现。
最重要的是怪异模式是否开启。不幸的是,您无法在网络邮件设置中控制它。表格和内联样式是您的朋友。最好的选择是在尽可能多的网络邮件和桌面客户端中进行测试。
Whether or not you include the html/head/body tags is entirely irrelevant — they are always optional and will not affect the rendering of the document in any way.
What matters most is whether quirks mode is on or not. Unfortunately, you can’t control that in a webmail setting. Tables and inline styles are your friends. Your best bet is to test in as many webmail and desktop clients as you can.
该线程上的许多帖子都相当陈旧,因此它们不再准确。
如今,如果您打算做任何花哨的事情,HTML 电子邮件应该包含文档类型、html 和正文声明。
关于这个主题有很多指南可以帮助您学习如何正确编码 HTML 电子邮件,但大多数指南都忽略了文档类型的细节,这就是我偶然发现您的问题的原因。
我建议您阅读以下两篇文章,它们来自熟悉各种问题的知名团队:
活动监视器的记录
关于 Acid 的电子邮件
Many of the posts on this thread are rather old, and as a result they are no longer accurate.
These days HTML emails should include a doctype, html and body declaration if you intend to do anything fancy at all.
There are a multitude of guides on this subject which can help you learn how to properly code HTML Email, but most of them disregard the specifics of a doctype, which is how I stumbled on your question.
I suggest you read the following 2 posts which are from reputable teams familiar with the various problems:
campaign monitor's take
email on acid's take
完全取决于接收它的电子邮件客户端。根据我的经验,大多数解释 HTML 的电子邮件客户端并不关心您是否有完整的 body/head/html 标签等。事实上,大多数浏览器甚至不需要这些标签。您需要有头标签来包含样式/标题等。否则它们本身并不是真正必要的。我从来不认为它们是必要的。
Depends entirely on the email client that receives it. In my experience, most email clients that will interpret HTML don't care if you have full body/head/html tags, etc. In fact you don't even need those tags for most browsers. You need to have the head tags to include style/title, etc. Otherwise they are not really necessary, per se. I've never seen them to be necessary.
我知道有一件事是正确的:使用 HTML 开始和结束标签将有助于一般垃圾邮件评分,因为许多此类基于设备的过滤器和软件防火墙会向使用 html 但不使用 html 的电子邮件添加一个点左右开始和结束标签。
There's 1 thing I know to be true: Using HTML opening and closing tags will help in general spam scoring due to the fact that many such appliance based filters and software firewalls will add a point or so to an email that uses html but does not use the opening and closing tags.
我认为没有正确的方法,但尝试让电子邮件在尽可能多的电子邮件阅读器中可见。
我通常在 Thunderbird 中查看电子邮件,因为 Outlook 更宽容。
在 Thunderbird 中,这是电子邮件的 HTML 代码(我有一个显示 html 的扩展)
顺便说一句,我每次都对所有网络表单使用纯文本电子邮件。我在使用 html+纯文本电子邮件发送黑莓电子邮件时遇到了很多问题。
I don't think there is a right way but trying to make the email viewable in as many email readers as posible.
I usually check the emails in Thunderbird, because Outlook forgives more.
In Thunderbird this is the HTML code for an email (i have an extension that shows the html)
BTW, i use plain text email for all my web forms every time I can. I had many issues with blackberry email using html+plain text emails.