Whenever you create an HTML document, the doctype is the first thing placed in the document.
It conveys the web browser about the version of the HTML, this page is written on. It is not casesensitive.
Let us see an example displaying DOCTYPE on the top −
Example
<!DOCTYPE html> <html> <head> <title>Document Title comes here</title> </head> <body> <h1> Demo Heading </h1> This is the demo text. </body> </html>
Output
Now let us see some of the declarations for doctype −
HTML5 Declaration
Example
<!DOCTYPE html>
HTML 4 Strict
This document type includes all HTML elements except those that have been deprecated, and those that appear in frameset documents.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "https://www.w3.org/TR/html4/strict.dtd">
HTML 4 Transitional
This document type includes all HTML elements including those that have been deprecated −
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">;