HTML5 Doctype Declaration

According to HTML standards, each HTML document requires a document type declaration (DOCTYPE). The <!DOCTYPE> declaration is not an HTML tag; it tells the user agents (web browsers, web crawlers, validation tools) what type of document the file is. It ensures that the user agents correctly parse the HTML as you intended it.

<!DOCTYPE html>


The example above is a DOCTYPE declaration used for HTML5 which is very short. It is an instruction to the web browser about which version of HTML the page is written in. Although the version is not specified in the declaration but this one is determined for HTML5 actually.

The DOCTYPE for HTML5 is case-insensitive, so you can also use it like ─

<!doctype html>

How to Use HTML5 Doctype

Every HTML file must begin with this <!DOCTYPE> declaration before the <html> tag. Just like the following example ─

<!DOCTYPE html>
<html lang="en">
  <!-- Insert your content here -->