heikkim
heikkim

Reputation: 2975

Should HTML-emails begin with <html><body><head>...?

Should an HTML email message begin like any valid HTML-document and should it even have a DOCTYPE declaration?

Upvotes: 18

Views: 13928

Answers (3)

ilanco
ilanco

Reputation: 9957

Mail clients are not web-browsers. They support a small subset of HTML and almost every client behaves differently parsing those HTML elements. Therefore elements like html, head, body or DOCTYPE are irrelevant and usually discarded by the mail client.

From Wikipedia:

HTML mail allows the sender to properly express quotations (as in inline replying), headings, bulleted lists, emphasized text, subscripts and superscripts, and other visual and typographic cues to improve the readability and aesthetics of the message, ... Long URLs can be linked to without being broken into multiple pieces, and text is wrapped to fit the width of the user agent's viewport, ... It allows in-line inclusion of tables, as well as diagrams or mathematical formulae as images...

Upvotes: 3

kamelkev
kamelkev

Reputation: 1156

HTML emails should include a doctype, html and body declaration if you intend to do anything fancy at all.

There are a multitude of guides on this subject which can help you learn how to properly code HTML Email, but most of them disregard the specifics of a doctype, which is how I stumbled on your question.

I suggest you read the following 2 posts which are from reputable teams familiar with the various problems:

campaign monitor's take

email on acid's take

Upvotes: 17

Exalt
Exalt

Reputation: 53

No, since most email clients strip out the <html> and <body> tags and replace them with their own (see hotmail).

As for the doctype, see: http://www.campaignmonitor.com/blog/post/3317/correct-doctype-to-use-in-html-email/

Assuming you're using a table for your layout (you should be) you'd have one all encompassing table that effectively acts as your <body> element, and then nested within you'd have the rest of your content positioned within other tables.

Upvotes: 3

Related Questions