If you do not put it there, each browser will render your page in quirks
mode. Each browser interprets quirks mode more or less differently
depending on the day of the week, the phase of the moon, and the conjunction
of the planets. If you are not so concerned about browser renderings of
your pages, then this will be fine.
Also, if you do not put it there, your page will not validate according to
the W3C's rules for valid HTML 4.01.
If you put it there, then each browser will know that you are using standard
HTML 4.01 Transitional code and methods. You will still encounter browser
rendering differences from one browser/platform to another, but there will
be fewer than in quirks mode. In addition, your pages MAY validate with the
HTML 4.01 specs, depending on the usages you have applied on the page.
Here's a good example:
This page -
<html>
<head>
<title>Invalid</title>
</head>
<body>
<table bgcolor="red" height="100%" width="100%">
<tr>
<td>words</td>
</tr>
</table>
</html>
will fill the page horizontally and vertically with red color, even though
the content of the table is just one word. But the code on the page is
invalid, since table height is not (and never has been) part of the HTML
specification. The notion is that any container should be 'shaped' by its
contents. Quirks mode has attempted to interpret what you wanted to happen,
and (in this case) has made the right choice.
Add your doctype to this page, e.g.,
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Invalid</title>
</head>
<body>
<table bgcolor="red" height="100%" width="100%">
<tr>
<td>words</td>
</tr>
</table>
</html>
and the page will NOT fill with color because the browser is looking for
standard HTML, and table height doesn't qualify.
How do you know what to do, then? Well, the only way really is trial and
error. And reading.... And this forum among others.