This article is here to provide you more info on the
importance of using the right document type "doctype
" when you build your html pages.
HTML has it's own standards and this is the reason why each HTML page should have at the very first line a document type declaration which will tell the validator how to check the syntax of our document (HTML page).
Ok so what's a validator you would ask. In a simple line, the validator will tell you if the page uses the right right syntax, if it has errors and so on. There are lots of reasons why you should ask yourself if your pages are built the right way.
We have more than one examples of a "doctype
" so let's start with the first one here:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
This example of "doctype html public" will declare our html page as being "HTML 4.01 Scrict which is another version (trimmed down a little) of HTML 4.01 where some elements, frames, attributes, link targets etc. are not allowed to be included. By using the sctrict mode, web developers can build accessible and structurally rich pages that will work better in conjunction with CSS files. However, on browsers that don't support style sheets, HTML 4 Strict might fail it's mission.
Some other example of doctype
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
This doctype declares our html page as being "HTML 4.01 Transitional" which will have all the elements of "HTML 4 Strict" plus the missing attributes, frames, link targets etc.
We can also use this one which will declare our html page as being HTML 4.01 Frameset and it is used for declaring documents that are built with frames:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
The following one makes our document XHTML 1.0 Strict which is an XML version of HTML 4 Strict
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
XHTML 1.0 Transitional - you've guessed already - it's the XML version of HTML 4.01 Transitional.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
And of course, for XHTML documents that use frames we have the XML version of the HTML 4.01 Frameset:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
And, oldies but goldies, a doctype that is supported by most broesers out there only that it has a small support for CSS files and everything that we mentioned at HTML 4 doctypes.
The last one (or should we call it the first?) has limited support for most of things, I don't know if it's still used but to complete our lesson:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
As you can see, it's very important to declare our "doctype
" in order to tell the browsers what they're reading and the most important thing HOW should interpret the code, output the page etc.