The doctype, or document type declaration, is a line of code placed at the top of an HTML or XML document before the opening <html> tag. The doctype is used to specify the version of HTML or XML in which the document is written and to inform the web browser how to interpret and render the document.
In HTML, the doctype is used to specify the version of HTML that the document is written in.
The most commonly used doctype for HTML5 is:
This doctype is called an “HTML5 doctype,” and all modern web browsers support it. Using this doctype triggers the browser to render the webpage in “Standards mode,” which means that the browser will interpret the HTML and CSS code according to the World Wide Web Consortium (W3C) standards.
In XML, the doctype is used to specify the version of XML that the document is written in and to provide a link to the DTD (Document Type Definition) that defines the structure and elements of the document.
In summary, The doctype, or document type declaration, is a line of code placed at the top of an HTML or XML document before the opening <html> tag. The doctype specifies the version of HTML or XML in which the document is written and informs the web browser how to interpret and render the document. In HTML, the doctype is used to specify the version of HTML the document is written in; the most commonly used doctype for HTML5 is <! DOCTYPE HTML>, which triggers the browser to render the webpage in “Standards mode” according to the standards set by the World Wide Web Consortium (W3C). In XML, the doctype is used to specify the version of XML that the document is written in and to provide a link to the DTD (Document Type Definition) that defines the structure and elements of the document.
Also, See: Document Type Definition (DTD)