The purpose of a doctype is to tell the browser what version of html you are writing on your page. It should therefore be the first bit of information at the top of your html document, before you open up your html.
If you're using HTML 5 it should look like this:
<!DOCTYPE html>, which is quite a bit shorter than the other nine types that are out there.
Kind of irrelevant information now, but one thing I found interesting is that the reason that the HTML5 declaration is so short is that technially it doesn't even have what's referred to as a DTD, or Document Type Definition.
Here's the doctype for HTML 4.01 Strict:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
HTML is the root element of the document, as in
<html></html>. Then everything else further describes the DTD. Since HTML5 doesn't use a DTD there's really nothing else to declare.
Going a little bit further down the rabbit hole to figure out why HTML 5 doesn't have a DTD, I ran across this StackOverflow answer that made it pretty clear.
DTDs have been regarded by the designers of HTML5 as too limited in expressive power, and HTML5 validators (basically the HTML5 mode of http://validator.nu and its copy at http://validator.w3.org) use schemas and ad hoc checks, not DTD-based validation.
Moreover, HTML5 has been designed so that writing a DTD for it is impossible. For example, there is no SGML way to capture the HTML5 rule that any attribute name that starts with “data-” and complies with certain general rules is valid. In SGML, attributes need to be listed individually, so a DTD would need to be infinite.
Fascinating!! And actually, understanding this about the DTD will make it way easier to solidly remember the doctype for html. (Not that it was that hard anyhow!)