أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.
doctype or DTD is a Document Type Definition.The DTD is an instruction that associates a particular SGML(Standard Generalized Markup Language) or XML document for defin the type of document .
exemple : for create XHTML Mobile Profile DTDs you need to insert this instruction in first place
<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile1.0//EN" "http://www.wapforum.org/DTD/xhtml-mobile.dtd">
The doctype declaration should be the very first thing in an HTML document, before the tag. The doctype declaration is not an HTML tag; it is an instruction to the web browser about what version of the markup language the page is written in. The doctype declaration refers to a Document Type Definition (DTD).
In HTML5, the only purpose of the DOCTYPE is to activate full standards mode. Older versions of the HTML standard gave additional meaning to the DOCTYPE, but no browser has ever used the DOCTYPE for anything other than switching between quirks mode and standards mode.
Believe it or not! The layout Engine used by Web Browsers to render web pages uses3 different modes & can still render legacy old HTML!Long story short ...During the old browser wars, there were no stanndards in rendering HTML content into browsers, so web pages were written in two versions, Netscape Navigator and Internet Explorer, developers had to write a version of thier page that works for IE & the other for Netscape, then when the W3C (World Wide Web Consortium) took over defining Web Standards, Browsers were simply not able to use the new standards to render the old pages written for Legacy browsers.
Therefore, browsers introduced two modes to treat new standards defined by the W3C & support older html as well.There are now three modes used by the layout engines in web browsers: quirks mode, almost standards mode, and full standards mode. In quirks mode, layout emulates nonstandard behavior in Navigator4 and Internet Explorer5.
This is essential in order to support websites that were built before the widespread adoption of web standards. In full standards mode, the behavior is (hopefully) the behavior described by the HTML and CSS specifications. In almost standards mode, there are only a very small number of quirks implemented.
In Firefox, select View Page Info from the context menu, and look for Render Mode.If you use DOCTYPE you will see Standards Mode, if you remove the DOCTYPE, you should see Quirks Mode
In IE, you should find that in Developer Tools
To see the differences between the2 modes, see this link
Quirks Mode behaviour in FireFox
Make sure you always use the DOCTYPE so your browser better complies with the new Standards.
DOCTYPEs are required for legacy reasons. When omitted, browsers tend to use a different rendering mode that is incompatible with some specifications. Including the DOCTYPE in a document ensures that the browser makes a best-effort attempt at following the relevant specifications.
Simply doctype tell the browser how to deal with webpage: in other words its declaration for browser to tell what type of page you are dealing with and what conditions to apply.
It's an element inside the DTD file.
This element tells any browser (Google Chrome, Opera etc) that the document opened by it is an HTML file.