Swapna Kumar Panda
Swapna Kumar Panda

@swapnakpanda

12 ุชุบุฑูŠุฏุฉ 1 ู‚ุฑุงุกุฉ Mar 23, 2023
Twitter
<!๐ƒ๐Ž๐‚๐“๐˜๐๐„ ๐ก๐ญ๐ฆ๐ฅ>
<html>
<body>
๐–๐ก๐ฒ ๐๐จ ๐ฐ๐ž ๐ง๐ž๐ž๐ ๐ข๐ญ?
</body>
</html>
An HTML ๐Ÿงต
โžŠ History
โฌ˜ Towards the end of the 1990s, pages were written separately for
โžค Netscape Navigator
โžค Microsoft IE.
โฌ— When the web standards were made at W3C, browsers could not just start using them, as doing so would break most existing sites on the web.
โฌ™ These browsers, therefore, introduced 2 separate modes to treat new standards-compliant sites differently from old legacy sites.
โฌ– Modes were
โžค Standards Mode
โžค Quirks Mode
โฌ˜ For HTML documents, browsers use DOCTYPE at the beginning of the document to decide which mode to handle.
โฌ— The reference to DOCTYPE is actually borrowed from SGML to HTML.
โž‹ Doctype
โฌ˜ In HTML, the doctype is "required" to ensure that the browser makes a best-effort attempt to follow the relevant specifications.
โฌ— Doctype is "not" an HTML element, but rather a special instruction to the browser.
โฌ™ If specified,
โœ” it has to be at "the beginning" of the HTML document
โœ” just after the Byte-Order-Mark (BOM) if any
โฌ– The DOCTYPE for HTML5 is "case-insensitive" and can be written as
< !DOCTYPE html >
โžŒ Formats of Doctypes
There are 3 types
โžค Normal
โžค Deprecated
โžค Legacy Tool Compatible
Examples:
โžค Normal (HTML5)
<!DOCTYPE html>
โžค Deprecated (HTML 4/4.01, XHTML 1.0/1.1)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
โžค Legacy Tool Compatible
<!DOCTYPE html system "about:legacy-compat">
โž What if Doctype is not specified?
โฌ˜ Browsers will switch into "Quirks Mode" when rendering a document.
โฌ— Quirks Mode "may be" incompatible with some standard specifications.
โฌ™ Handling of Quirks Mode varies from browser to browser.
โฌ– Hence, the document may "render differently" in different browsers.
โžŽ What if Doctype is specified?
โฌ˜ Browsers will render the document in "Standards Mode".
โฌ— From the doctype, the corresponding HTML version is found, and thus the browser would know about the required standards.
๐Ÿ Let's summarise
โฌ˜ "<!DOCTYPE html>" is a required preamble found at the top of all HTML documents.
โฌ™ Its sole purpose is to prevent a browser from switching into โ€œQuirks Modeโ€ when rendering a document.

ุฌุงุฑูŠ ุชุญู…ูŠู„ ุงู„ุงู‚ุชุฑุงุญุงุช...