On the HTML document you have often seen that there is a <!DOCTYPE html> declaration before the <html> tag. This <!DOCTYPE html> declaration is not an HTML tag. It is used to instruct the web browser about the HTML page.
Actually, there are many type of HTML e.g. HTML 4.01 Strict, HTML 4.01 Transitional, HTML 4.01 Frameset, XHTML 1.0 Strict, XHTML 1.0 Transitional, XHTML 1.0 Frameset, XHTML 1.1 etc.
The <!DOCTYPE> declaration refers Document Type Declaration (DTD) in HTML 4.01; because HTML 4.01 was based on SGML. But HTML 5 is not SGML based language.
DTD defines the rules for the markup languages so that the browsers recognize the content correctly.
The doctype declaration differs between HTML versions. The HTML 5 doctype declaration is given below.
Let's see an example of HTML document with doctype declaration.Test it Now
Note: It is always a good practice to add a declaration to your HTML documents to enable web browser to recognize that what type of document to expect.
Note: DOCTYPE declaration is not case sensitive.