[英]The CSS from my email templates does not work on yahoo email
I have built a few email templates the issue is that the CSS is not working on yahoo / outlook / windows native app etc. Pretty much anything that is not mac or google.我已经构建了一些 email 模板,问题是 CSS 在 yahoo / outlook / windows 本机应用程序等上不起作用。几乎所有不是 mac 或 google 的东西。
I did write the templates using tables but for the CSS I used the style tag because I want the templates to also be responsive.我确实使用表格编写了模板,但对于 CSS,我使用了样式标签,因为我希望模板也能响应。
I will leave some code examples below maybe you can point out my mistake.我将在下面留下一些代码示例,也许您可以指出我的错误。
<style type="text/css" data-hse-inline-css="true">
* {
margin: 0;
padding: 0;
}
body {
background-color: #ebeff5;
font-family: 'Source Sans Pro', sans-serif;
}
table,
tr,
td {
margin: 0;
padding: 0;
}
table {
border-spacing: 0;
}
img {
width: 100%;
border: 0;
}
p {
font-size: 20px;
color: #39506f;
line-height: 30px;
}
a {
text-decoration: none;
cursor: pointer;
}
.wrapper {
width: 100%;
table-layout: fixed;
background-color: #ebeff5;
}
.main {
background-color: #ebeff5;
margin: 0 auto;
width: 100%;
max-width: 750px;
padding: 35px 15px;
}
.spacing-one {
height: 15px;
}
.spacing-two {
height: 25px;
}
.card {
padding: 20px;
background-color: #ffffff;
border-radius: 5px;
}
.main-font {
font-size: 30px;
color: #1b3040;
font-weight: 400;
}
...
<main class="wrapper">
<table class="main">
<tr>
<td class="card">
<table width="100%">
<tr>
<td>
<img
class="logo"
src="path"
alt="logo"
/>
</td>
</tr>
<tr class="spacing-two"></tr>
<tr>
<td>
<h1 class="main-font">Hey {{name}},</h1>
</td>
</tr>
<tr class="spacing-one"></tr>
<tr>
<td>
<p>text.</p>
</td>
</tr>
<tr class="spacing-one"></tr>
<tr>
<td style="height: 56px">
<a href="{{url}}" target="_blank">
<span class="main-button"
>Reset Password
<img
class="main-button-icon"
src="path"
alt=""
/></span>
</a>
</td>
</tr>
<tr class="spacing-one"></tr>
<tr>
<td>
<p>
text.
</p>
</td>
</tr>
</table>
The biggest issue here is that not all email clients support HTML5 semantics (like the <main>
tag you're using).这里最大的问题是并非所有 email 客户端都支持 HTML5 语义(比如您正在使用的
<main>
标签)。 And email clients will behave very differently in how they do not support it.而 email 客户端在不支持它的方式上表现得非常不同。 You can refer to Can I email for details on support of HTML5 semantics .
HTML5语义的支持可以参考Can I email。
For example, Gmail does not support the <main>
tag.例如,Gmail 不支持
<main>
标签。 But it will change it into a <div>
element and apply the same class
attribute you had in the first place, making this seamless.但它会将其更改为
<div>
元素并应用您最初拥有的相同class
属性,从而实现无缝连接。
Yahoo, however, will remove the <main>
element completely, thus also removing the styles you wanted to apply on it.然而,Yahoo 将完全删除
<main>
元素,因此也删除了您想要应用的 styles。
In your case, changing <main class="wrapper">
into <div class="wrapper">
is enough to make it work in Yahoo.在您的情况下,将
<main class="wrapper">
更改为<div class="wrapper">
足以使其在 Yahoo 中工作。
This might not be enough for Outlook on Windows and Windows native client as both of those use Word as a rendering engine and have very poor support for CSS. Thinks like margin:0 auto
or max-width
won't work.这对于 Windows 上的 Outlook 和 Windows 本机客户端来说可能还不够,因为它们都使用 Word 作为渲染引擎并且对 CSS 的支持非常差。认为
margin:0 auto
或max-width
将不起作用。 You will have to rely on conditional comments, tables and eventually mso
specific styles to get a proper rendering for Outlook on Windows.您将不得不依赖条件注释、表格和最终
mso
特定的 styles 才能在 Windows 上正确呈现 Outlook。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.