Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 508
norwebian Avatar asked Nov 01 '10 13:11

norwebian


1 Answers

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.

like image 66
bobince Avatar answered Oct 14 '22 11:10

bobince