Services

Featured Sites

24K Music Videos

HTML Doctypes & Validation

The HTML doctype declaration is not a tag; it is more like an instruction that tells the web browser what version of HTML is used on the page. Some browsers require a doctype declaration in order to render the webpage correctly, so it is good practice to include one.

The doctype declaration is placed at the very beginning of an HTML document, even before the opening <html> tag.

<!DOCTYPE html>
<html>
<head>
  <title></title>
</head>
<body>
</body>
</html>

The doctype declaration that is used will depend on the version of HTML that you are using. Each declaration refers to a Document Type Definition, or DTD.

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

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

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

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

I can already hear you asking "But which doctype should I use?!". Good questions. I suggest "<!DOCTYPE html>" for HTML5, as any new pages from here on out should make use of the latest version of HTML!

Once you have chosen your doctype you can validate your webpage to have all of the HTML errors pointed out to you, usually followed by a self-inflicted smack to the forehead, which can be accompanied by a roll of the eyes and a muttered "How could I have missed that?", all of which are, of course, optional.