Is safe to put html style tag into body tags coding html emails?

孤者浪人 提交于 2019-12-14 03:50:30

问题


I am coding a html email template. All my code is inline. There are media queries between <style> tag inside the <head> tag.

Can I put the <style> tag inside the <body> tag?
Would that work with all major email clients?


回答1:


It seems client dependent. Check out a similar answer here.

Some clients will support the use of styling in the body, but generally not in the head. Since there is really no way to incorporate css, it makes sense that this would be the case.




回答2:


Style tag inside the body has almost identical compatability to a style tag in the head. Each client offers different quirks with this, so overall I would recommend using style in head unless you are unable to.

For example Gmail will strip the style tag regardless where you put it. Your best bet is to test continuously using a service like Litmus or Email on Acid.

Good reference for CSS compatability in email is https://www.campaignmonitor.com/css/



来源:https://stackoverflow.com/questions/31686103/is-safe-to-put-html-style-tag-into-body-tags-coding-html-emails

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!