Language First

It is amazing how many people write the content of their web page first and then decide that they need to add a doctype to the page. There are so many people asking which doctype that they should add to an already written web page.

Their question is of course complete nonsense. In order to write a web page you need to decide first which markup language you are going to use to write it. Just as you need to decide whether you are going to write the content in English, Dutch, Africaans, or whatever before you can start writing the content, you also need to decide what markup language you are goung to use to do the markup before you start applying tags to your content. The doctype in most instances identifies which particular markup language you have selected to use to markup your page.

The only doctype that does not imply a specific version of (X)HTML is the short version.

<!DOCTYPE html>

That particular doctype simply indicates that you are using a version of HTML other than version one (which didn't use a doctype as it wasn't based on SGML) or a version of XHTML. It doesn't say anything about which particular version of (X)HTML that you are using beyond that.

Browsers do not really look at trying to actually use the doctype in determining what they will do with the markup. Browsers just use the presense or absence of the doctype as a switch to determine whether the page should be displayed according to the standards or according to the browser specific rules that applied back in the 20th Century before the standards were finalised. Since all new pages should follow the standards, all new web pages should have a doctype.

That doctype doesn't help much when it comes to actually ensuring that the (X)HTML you are using is valid though. You can use proprietary tags that only one browser recognises with that doctype and still end up with a web page that only works in that browser and not others. It's like throwing a few german and Tagalog words into sentences written in English and totally confusing everyone who doesn't know all the languages.

To be able to write your (X)HTML properly you will need to use a longer variant of the doctype where you identify which version of (X)HTML you are using. That way you will be able to feed the finished page through a validator that will confirm that all of the markup used is valid for that version and complies with that particular standard. Only then will you be able to know that your web page will work in all standard compliant browsers.

Unless you have a specific reason for deciding to write your markup using XHTML, you should use the latest version of HTML. At the time of writing this the latest HTML standard is 4.01 and the doctype to use to write your markup is:

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

 

This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow
Donate