user3141927
user3141927

Reputation: 5

HTML email coding

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

Answers (2)

Rudick Astock
Rudick Astock

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

Chris Pratt
Chris Pratt

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

Related Questions