<!DOCTYPE> Explained – What Is a Document Type Declaration?
A <!DOCTYPE> declaration informs browsers about a document's type and version.
Example of an HTML Document with a Doctype Declaration
<!DOCTYPE html> preamble in the snippet below tells web browsers that the page is an HTML5 document type.
<title>Your document's title</title>
<!-- Space for the documents's content such as <p>, <div>, and <img> elements -->
Note the following:
<!DOCTYPE>declaration is not an HTML tag. It is a preamble for declaring information about a document to web browsers.
- It is essential to declare your document type before defining other HTML elements.
<!DOCTYPE>declaration is case-insensitive. So, browsers interpret
<!DocType>as equivalent document type declarations.
The article discussed what a
<!DOCTYPE> is. We also used an example to understand how to define it in an HTML document.