Html 您可以从电子邮件链接到 CSS 文件吗?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2105963/
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 01:55:30  来源:igfitidea点击:

Can you link to a CSS file from an email?

htmlcssemailstylesheet

提问by Josh Curren

When sending an HTML email can you link to an external style sheet or does the CSS need to be included in the email?

发送 HTML 电子邮件时,您是否可以链接到外部样式表,或者是否需要将 CSS 包含在电子邮件中?

Also, if you can link to an external style sheet, which way is more efficient/is smarter to use: linking to the style sheet or including it in the HTML?

此外,如果您可以链接到外部样式表,哪种方式更有效/更智能:链接到样式表或将其包含在 HTML 中?

回答by bobince

Forget efficient. Forget smart. Forget maintainable. This is HTML mail we're talking about.

忘记效率。忘记聪明。忘记可维护性。这是我们正在谈论的 HTML 邮件。

HTML mail and Webmail clients are extremely limited, partly for security reasons but mainly because they're just rubbish. External style sheets almost certainly won't work. HTML-embedded style sheets probably won't work. Inline style="..."attribute on every damn element... has a much better chance of working, but still, don't be surprised when many users can't see styles at all, or some styles don't work, or some basic HTML doesn't work, and the content ends up looking like a 1997 browser threw up all over it.

HTML 邮件和 Webmail 客户端非常有限,部分是出于安全原因,但主要是因为它们只是垃圾。外部样式表几乎肯定不起作用。嵌入 HTML 的样式表可能不起作用。style="..."每个该死的元素上的内联属性...有更好的工作机会,但是,当许多用户根本看不到样式,或某些样式不起作用,或某些基本 HTML 不起作用时,请不要感到惊讶。 t 工作,内容最终看起来像一个 1997 年的浏览器。

HTML mail is an exercise in unpleasantness. I hate to receive it. I hate even more to author it. The sanest route for everyone is to forget HTML mail and just send a plain text message including a link to a full web page, where you can have as much CSS, JavaScript and Flash loveliness as you like.

HTML 邮件是一种令人不快的练习。我讨厌收到它。我更讨厌创作它。对每个人来说,最明智的方法是忘记 HTML 邮件,只发送一条包含完整网页链接的纯文本消息,您可以在其中拥有尽可能多的 CSS、JavaScript 和 Flash。

回答by NotMe

Can you? Yes.

你是否可以?是的。

Should you? No. Most likely the email client will block external links and therefore your mail will not appear as you think it should.

你应该?不会。电子邮件客户端很可能会阻止外部链接,因此您的邮件不会像您认为的那样显示。

If you must send html mail, embed everything into the email message itself. External links which automatically call back to the home server to load additional resources are one thing spam filters don't like.

如果您必须发送 html 邮件,请将所有内容嵌入电子邮件本身。自动回调到主服务器以加载额外资源的外部链接是垃圾邮件过滤器不喜欢的一件事。

回答by Chris Roberts

You're best off embedding the CSS in your HTML.

最好将 CSS 嵌入到 HTML 中。

I believe inline styles (added in a style attribute on each element) are more widely supported than including a <style> section, too.

我相信内联样式(在每个元素的样式属性中添加)比包含 <style> 部分得到更广泛的支持。

I just Googled and came across this tutorial - looks pretty good at first glance... http://articles.sitepoint.com/article/code-html-email-newsletters

我刚刚用谷歌搜索并发现了这个教程 - 乍一看看起来很不错...... http://articles.sitepoint.com/article/code-html-email-newsletters