Home · Articles · Choosing a Doctype · Articles

articles

Choosing a Doctype

The choice of which doctype to use in your website is typically a no-brainer. You'd use the newest doctype because its recommended by the W3C and will give you the best support in the widest array of web browsers. So unless there is some special reason for you to use a legacy doctype, you would use the HTML5 doctype.

<!DOCTYPE html>

However, when coding HTML for emails, using the above doctype is not ideal because there are a whole number of elements and attributes that are still needed for email design. (i.e. cellpadding/cellspacing/align/width/etc.) – and these things are not a part of HTML5, and the W3C validator will throw errors if you validate your code with the HTML 5 doctype.

The HTML validation service will validate code against the kind of doctype that you have specified at the top of the code. So this definitely matters.

So for this reason, I recommend using the HTML 4.01 Transitional doctype. It's your safest bet.

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">

But if you’re not concerned with code validation, the HTML5 doctype is fine. Both of these doctypes will render Standards Mode.

Even though many web based clients already have their own doctype and will force us to use theirs, its always good idea to put a doctype in your emails to make them render in Standards Mode in web browsers, and to have fewer rendering issues.


Tue Nov 8th, 2016

This article hasn't been commented yet.

Write a comment

9 + 1 =