Skip to content
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

Why are the <style> tags in the <head>? Shouldn't they be in the <body>? #262

Open
marcelgruber opened this issue Apr 7, 2021 · 7 comments
Labels
question nothing reported, just asking a question

Comments

@marcelgruber
Copy link

Please consider this a general question. In my experience, some clients will ignore what's in the <head>, and in some cases they will nuke the entire contents of the head; particularly when emails are forwarded.

Can you think of any reason we shouldn't move the <style> content inside of the email body?

@TedGoas
Copy link
Collaborator

TedGoas commented Apr 7, 2021

No worries, questions are always welcome.

Can you think of any reason we shouldn't move the <style> content inside of the email body?

If it ain't broke, don't fix it. Honestly I've never come across a scenario or email client that hasn't applied styles in the <head>. If you can produce a scenario where this approach doesn't work, I'm open to changing things.

@TedGoas TedGoas added the question nothing reported, just asking a question label Apr 7, 2021
@marcelgruber
Copy link
Author

marcelgruber commented Apr 9, 2021

I certainly agree with your statement, and now I'm going to take this somewhere that might be out of scope entirely: forwarding emails! Of course at that point it's mostly out of our control and we're at the mercy of individual clients, but in all of the testing I've done lately, they nuke the <head> and a whole bunch of other things as well. IMO, it seems to be an easy win to move the styles somewhere in the body that might be "guarded" by the body content wrappers. I don't have any definitive experiments to back up my claim that it will help, but all I know is that <head>s will get nuked, and that many ESPs won't really let you touch the head to begin with...

@marcelgruber
Copy link
Author

Further, there are certainly some opportunities within this repo to move some of the non-media specific styles directly into the inline styles. But perhaps the goal with the styles in this repo was to be more of a reference than the end all be all of placement.

@TedGoas
Copy link
Collaborator

TedGoas commented Apr 12, 2021

Hey Marcel, I did some digging and learned that Gmail won’t render styles included in the body. So styles would need to be doubled up (or maybe just include some fixes in the body version). Is that your experience?

@marcelgruber
Copy link
Author

Gmail renders styles in the body with no issue. I believe they added support for that in 2016. I've been doing extensive testing after having moved the styles into the body area, and everything is looking good!

@cossssmin
Copy link

Gmail does not support styles in the <body> tag:

https://www.caniemail.com/features/html-style/

forwarding emails

Moving styles into the body of the email does not guarantee they'll work when the email is forwarded. Things like classes are often rewritten, rendering your CSS useless. Inlining is still the best we can do about that.

@TedGoas
Copy link
Collaborator

TedGoas commented Jun 30, 2021

@cossssmin In Cerberus most of the CSS is already inlined. In your experience, what sort of styles should be inlined and sometimes appear in the <head> that cause trouble with email forwarding?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question nothing reported, just asking a question
Projects
None yet
Development

No branches or pull requests

3 participants