Reputation: 5
I am altering an html email template created by previous designer. It doesn't look right to me:
<html style="margin: 0;padding: 0;border: 0;width: 100%;height: 100%;">
<head>
</head>
<style type="text/css">
I would have thought 'style' goes into 'head' and 'html style="..." looks confusing. I am not an expert on html emails, just thought somebody here might be more knowledgeable Also is there meant to be a doctype?
Upvotes: 0
Views: 138
Reputation: 1
Newsletter code is based on tables and all its styles are placed inline. Code like this looks archaic but there is a good reason for this - most email services don’t allow for proper positioning and shaping the format using such tags as div, section etc. and that’s why tables are used to build a newsletter.
See: http://freshmail.com/developers/best-practices-for-email-coding/ for a reference of what styling can and cannot be used. The guide includes also advice for newsletter designers and developers regarding Responsive Email Design
Upvotes: 0
Reputation: 239200
This was likely done because many email clients strip out the head
element. However, the style
element should go in the body
element at point. The only supported child elements of html
are head
and body
. Of course, even then, many email clients also strip out style elements, so really all CSS in an email template should be inline for maximum compatibility.
Upvotes: 1