New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Gmail removes <style> tags that contain certain @ declaration within an @ declaration #21
Comments
This bug is still present after the 2016 update. |
Hi. I was unaware of this behaviour! To confirm, would something like this trigger the described behaviour: @media screen {
@font-face {
/* Some font stuff */
}
}
Is the only solution to split out CSS styling into separate |
@jamesmacwhite the issue needs clarification, as it is not enough to have two ampersands within a style tag to cause Gmail to strip it. For example, this class will set the text to red. In the following example, Gmail ripped out the <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1" />
<meta http-equiv="X-UA-Compatible" content="ie=edge"/>
<title>Checking</title>
<style type="text/css">
@media screen {
@font-face {
font-family: 'Roboto';
src: url('http://secret-url/host/img/roboto-regular.ttf');
}
}
@media screen {
.red {
color: red !important;
}
}
</style>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td class="red" style="font-family: Roboto, serif;">
Text
</td>
</tr>
</table>
</body>
</html>
PS, I removed the domain of the hosted TTF for security purposes, but rest of the code is intact. Here's the screenshot of the test email proof in Gmail: If Gmail really stripped the whole |
@revelt Thanks for the further testing! There is a crucial difference in your test vs the original from @hteumeuleu, not sure if it makes a difference or not though. You put |
Hi you two. Very interesting. From @revelt's test, here are the styles Gmail keeps: @media screen{}
@media screen{div.m159bc71832e5f85a .m_4170545781705170558red{color:red!important}}
My initial test still produces the same result. So there seems to be something special going on with |
From my past experience with Gmail, if it finds any selectors that are not on the "supported" list, it will simply discard all the styles in head. I had this happening before when I used I see the original test uses |
Also, |
Gmail is also restricts media queries by location and by product not only the mentioned supported properties.
But those |
Should this be revisited? Perhaps rewrite the title and explanation to be more accurate. For example, |
@jkupczak Interesting. I clearly remember that nested media queries didn't work. I just tested with the following code and it does indeed work. <html>
<head>
<style>
p { background:#3cbc67 !important; }
@media only screen and (max-width:320px) {
@media only screen and (max-width:320px) {
p { background:#3cbc67 !important; }
}
}
</style>
</head>
<body>
<p style="color:#fff; background:#000;">
Lorem ipsum dolor sit amet, consectetur adipisicing elit.
</p>
</body>
</html>
|
@jkupczak So, it turns out Gmail does support nested media queries. But only if those are fully declared media queries. So the above example works. But <style>
h1 { background:#3cbc67 !important; }
@media only screen and (max-width:320px) {
@media {
h1 { background:#3cbc67 !important; }
}
}
</style>
…is transformed by Gmail into the following: <style>
h1 { background:#3cbc67 !important; }
</style>
What's interesting is that this falls more to a classic case of styles filtering, where only the |
The mainstream desktop webmail of Gmail removes
<style>
tags that contain an@
declaration within an@
declaration.The following code…
…is transformed by Gmail into the following :
The text was updated successfully, but these errors were encountered: