Html 我可以在电子邮件模板中使用 DIV 吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21899537/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-29 00:58:19  来源:igfitidea点击:

Can I use a DIV in an email template?

htmlemailtemplatesmailchimp

提问by Crookbud

I am greatly confused about designing an email template for a mailchimp campaign. I want to know if I can use a divwith a class of "Container" on my email template. Is using divtags supported by all mail clients? I am using DIV only for the container but in the inner part of the template I have used table, trand tdtags. Please let me know.

我对为 mailchimp 活动设计电子邮件模板感到非常困惑。我想知道我是否可以div在我的电子邮件模板上使用带有“容器”类的 。是否使用div所有邮件客户端都支持的标签?我仅将 DIV 用于容器,但在模板的内部使用了table,trtd标签。请告诉我。

Thanks.

谢谢。

回答by John

You can use div, however tables are supported more consistently. If you try to go the div route, you'll find some of your CSS will fail.

您可以使用 div,但更一致地支持表格。如果你尝试走 div 路线,你会发现你的一些 CSS 会失败。

Also, by going with tables, it opens up the old school html attributes that only work in tables. These include align, valign, bgcoloretc, all of which are 100% supported, while their CSS equivalents have partial support.

此外,通过使用表格,它打开了仅适用于表格的旧式 html 属性。这些包括alignvalignbgcolor等等,所有这些都是100%负载,而它们的CSS等价物具有部分支持。

On a side note, here are all the resources you will needto get started in html email.

附带说明一下,这里是开始使用 html 电子邮件所需的所有资源

回答by Harish Boke

There is no specifications for layout using table-less nor tables. However, using tables is the preferred way as it renders all at once. This aligns with how email templates render; while div's render separately. If you use div's include your css inline to the template as some clients do not support external css.

没有使用 table-less 或 table 的布局规范。但是,使用表格是首选方式,因为它可以一次性呈现所有内容。这与电子邮件模板的呈现方式一致;而 div 的渲染是分开的。如果您使用 div 将您的 css 内联到模板中,因为某些客户端不支持外部 css。

回答by Dan Dascalescu

As of April 2017, yes, you can use <div>tags in email. Outlook was the only major email client that didn't support them.

截至 2017 年 4 月,是的,您可以<div>在电子邮件中使用标签。Outlook 是唯一不支持它们的主要电子邮件客户端。

See https://github.com/rodriguezcommaj/principles-of-email-designand https://www.sendwithus.com/resources/templates

请参阅https://github.com/rodriguezcommaj/principles-of-email-designhttps://www.sendwithus.com/resources/templates