Your document will work without it. You could do
<html>
<head>
<title>My Web Page</title>
</head>
<body>
Hello World
</body>
</html>
- <html>
- <head>
- <title>My Web Page</title>
- </head>
- <body>
- Hello World
- </body>
- </html>
and the page will display just fine in most browsers, but it's not correct.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
is what's know as a "document type declaration (or definition)" (DTD). In essence it identifies to the browser the type of code that is being used in the document. When declaring a doctype, it is then your responsibility as a designer to code the page to the specifications you have "declared" you are using in the doctype. In your example, you are declaring to the browser that you will be writing your code to HTML 4.01 transitional specifications and that is what it is expecting. If you falter from those "expectations" then your code may become considerd as "invalid" and may not display correctly in some browsers.
This is where things start to get a little confusing. The transitional doctype was institituted to allow a transitional period for designers to migrate from older coding standards to newer coding standards. An alternative to a "transitional" doctype would be a "strict" doctype.
In the example you have provided the distinction would be that for a "strict" doctype to be valid and display correctly, then you must write the code for your pages specifically to HTML 4.01 standards, whereas using a "transitional "doctype would allow you to use depracated (i.e. obsolete) code from say perhaps, HTML 4.0 or HTML 3.2 and, although it's planned to eventually be elliminated would at least still work for the time being.
An example would be <font> tags. Very old coding practice and now depricated and has been replaced by using style instead.
For more on doctype declarations (a.k.a. DTD's) go here
http://www.w3schools.com/tags/tag_doctype.asp
(one of these days I need to do a complete tutorial on this.)
"The web is a dominatrix. Every where I turn, I see little buttons ordering me to Submit."
Play sports pools and discuss sports topics at Boasting Rights Sports Forum
Get paid to write articles - www.associatedcontent.com