Doctypes, short for "document type," is used to inform web browsers about the version of HTML that is being used to write a web page. By declaring the correct doctype, you can ensure that the web page is displayed correctly and consistently across different web browsers.
The doctype declaration should always be included at the top of the HTML document before the <html> tag. It is not an HTML tag but rather an instruction to the web browser about the HTML version.
HTML5 is not based on SGML (Standard Generalized Markup Language) and therefore does not require a reference to a DTD (Document Type Definition). The doctype declaration for HTML5 is as follows:
<!DOCTYPE html>
Case Insensitivity
According to the W3.org HTML5 DOCTYPE Spec, a doctype must consist of the following components, in this order:
A string that is an ASCII case-insensitive match for the string "<!DOCTYPE>".
Therefore, the following doctypes are also valid:
<!doctype html>
<!dOCtyPe html>
<!DocTYpe html>
Adding the correct doctype to your HTML document is an essential step in ensuring that your web page is displayed correctly and consistently across different web browsers. Please ensure to include the doctype declaration at the top of your HTML document and use the correct structure for the specific doctype you use.