Basically, if you have a doctype on your page, the browser sees it and thinks—OK, this web designer has some clue about what he's doing, so we'll render the page according to the prevailing web standards. If there's no doctype, the browser might decide to display your page in "quirks mode", as if it were built last century, and thus your layout will break in certain ways.

It doesn't really matter which doctype you use. These days, it's common to use the so called "HTML5" version, which is more of a generic doctype:

<!DOCTYPE html>

which ends up like this in the document:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">

sageshark
—
2013-04-03T09:57:02Z —
#3

Doctype help browser understand if the page is written using strict, transitional or frameset type html. Depending upon this declaration the page code will be validated in w3c validator.

Also doctype is necessary to make few elements of html work properly. It is an idea practice to include the doctype in your html page.

rammurtee
—
2013-05-30T06:51:02Z —
#4

Doctype specify the web standard you have used for writing code of your website.Each doctype has different rules and constraints