Your first document

The doctype

See why every HTML document begins with a short doctype declaration and how it keeps browsers in standards mode.

4 minute lesson

~~~

The first line in a modern HTML document is:

<!doctype html>

This is the document type declaration, usually called the doctype.

It tells the browser to render the page using standards mode. Without a recognized doctype, browsers can enter quirks mode, which imitates some old browser behavior so ancient pages do not break.

You do not want quirks mode for a new page.

The doctype is not an HTML element. It has no closing tag and does not belong inside the html element. Put it on the first line, before everything else.

You might see very long doctypes in old documents. Modern HTML only needs this short version. HTML is maintained as a living standard, so you do not need to put a version number in it.

Uppercase and lowercase both work, but this is the form I use:

<!doctype html>

Lesson completed