What is the purpose of <!DOCTYPE html> at starting of an HTML document?


Doctype is required in HTML document for legacy reasons. Its main purpose is to prevent the browser from entering 'Quirks Mode' while rendering the document.

Including the DOCTYPE in a document ensures that the browser makes the best-effort to follow standard specifications. The doctype should be included at the beginning of the HTML document as shown in the example, below.

<!DOCTYPE html>
    <title>Including Doctype in HTML Document</title>
      Including Doctype in HTML Document
      Welcome to hackinbits.com

In HTML5, Doctype's only purpose is to activate the full standard mode.

Share and support us

Share on social media and help us reach more people