Reputation: 23
Why we are using in every Html document? . Without that doctype also it is executing the website , then why we have to mention that doctype.
Upvotes: 2
Views: 175
Reputation: 1155
< !DOCTYPE html> -- is html5 standard. By declaring like that your saying to webpage that it is html page which can browser read.
If you see any pdf or xml other text files also browser can read, so by adding DOCTYPE in html, we are this is html document to browser
Upvotes: 0
Reputation: 7107
<!DOCTYPE>
-
Definition and Usage
The declaration must be the very first thing in your HTML document, before the tag.
The declaration is not an HTML tag; it is an instruction to the web browser about what version of HTML the page is written in.
In HTML 4.01, the declaration refers to a DTD, because HTML 4.01 was based on SGML. The DTD specifies the rules for the markup language, so that the browsers render the content correctly.
HTML5 is not based on SGML, and therefore does not require a reference to a DTD.
Tip: Always add the declaration to your HTML documents, so that the browser knows what type of document to expect.
From : W3 schools HTML Declaration
Upvotes: 2