<!DOCTYPE html>

What is it?

<!DOCTYPE html> is a declaration at the beginning of an HTML file. It identifies the document as HTML. Unlike an HTML element, the DOCTYPE declaration does not use an opening and closing tag and does not contain attributes or values. [1] [6]

Why is it used?

It tells the browser to display the page using modern HTML standards. [1] [6]

Example on This Page

Look at the very first line of this page’s HTML file: <!DOCTYPE html>. It appears before the <html> element and tells the browser that this is an HTML document. It is a declaration, not an HTML element, so it does not have attributes or a closing tag.

Screenshot showing the DOCTYPE declaration at the start of an HTML file
The DOCTYPE declaration appears before the opening HTML tag.
Source: Screenshot of example from [1]

What I Learned

While making this page, I learned how to display < and > as text by using the less than and greater than character codes. I also used the code element to make it clear that I was showing HTML syntax. Finally, I learned how to link a citation to my references page using the same kind of link I use for navigation.