开发者

What doctype to use when generating HTML mail

I'm working on a CMS website which sends newsletters based off an HTML page (and with a conversion to plain text as a multipart/alternative option). I wonder what would be the best practise for choosing doctype.

The design for these pages are of course simplified from the real website, and getting the right doctype for the page as such is trivial - but then again: this newsletter page will be shown in various "browsers", from gmail to Outlook. Webbased email clients will have their own doctype already in place, and locally installed email clients will probably have different engines, probably with different requirements.

So, what - if开发者_运维百科 any - doctype should be used in the HTML mail?


You can and should include the doctype that best describes what format your document is written to.

But that's just as a matter of correctness; don't expect it to actually have any tangible effect. As you note, webmail services display the HTML as part of their own document, meaning you don't get to choose between Quirks and Standards Mode. Desktop clients often have their own decrepit HTML renderers from way back before Quirks and Standards existed; they will just ignore the doctype. And both types of client will mangle your HTML in much worse ways than just that implied by Quirks Mode. HTML mail is a world of endless woe.


I usually test with and without a doctype.

Essentially you want your html looking the same in standards mode and quirksmode; For example, avoid setting CSS padding+width (box model incompatibilities) and test to see which deprecated attributes work in quirksmode but not in standards mode.


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/strict.dtd">
<html>
<head>
 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
 <title>Message from {shop_name}</title>
</head>

this is what's used by prestashop and works pretty well so

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜