Using Doctypes
Doctypes are perhaps the most important code snippet you will ever include in your webpages. They tell the browser which specification of (X)HTML you’re using, which in turn let the browser know how to interpret the coding and display it to the visitor.
The majority of webpages will display correctly without a Doctype, so you may be wondering what all the fuss is about. Why bother if the browser can cope without it? Surely that just adds superfluous bytes to the size of your document? No! The only reason documents work without a Doctype is because the browser guesses! It guesses which specification you’re using, and it’s just luck that results in the page being displayed as you intended. Are you comfortable with that? I know I’m not… I don’t want my visitors’ browsers to guess how to display my site. I want them to be 100% sure how to display it, which is why I use a Doctype.
HTML Doctypes
HTML Strict DTD
If you use correct HTML tags, and have your styling separated from your content using CSS, then this is the doctype you should be using.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
HTML Transitional DTD
If you expect that your visitors are using browser that don’t support CSS (rare, but it happens), and you’re using the <font> tag etc., then this is the doctype you should be using.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
Frameset DTD
If you’re using frames (*gasp*), then this is the Doctype you’ll need.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
XHTML Doctypes
XHTML Strict DTD
If your coding is immaculate and you’ve separated all your styling from your content, use the Strict Doctype to let the brower know how awesome you are. =p
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
XHTML Transitional DTD
This Doctype is less ’strict’ than the strict Doctype (for want of a better phrase). If you’re currently making the change from HTML to xHTML, this is probably the best doctype for you to use.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
XHTML Frameset DTD
If your site uses frames (whether standard or inline), you need to let the browser know this using the Frameset Doctype.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">









