Things you might not know about DOCTYPE in HTML.

RanveerSequeira
2 min readNov 21, 2021

--

  1. DOCTYPE is the first piece of code to write in HTML5 to inform a browser that the document being rendered is an HTML document. <!doctype html>, <!Doctype HTML> or <!DOCTYPE HTML> all are the same because the doctype keyword is not case-sensitive.
  2. Is DOCTYPE declaration considered as HTML Tag?
    Ans — The declaration is not an HTML tag. It is an “information” to the browser about what document type to expect.
  3. Modes that are defined by layout engines in web browsers.
    1. Quirks Mode — It refers to a strategy used by some web browsers to preserve backward compatibility with web pages built for old web browsers, rather than solely complying with standard W3C and IETF requirements in the standards' mode.
    2. Almost Standards — This mode rendering matches “full standards” mode in all details except, the image layout inside table cells is treated in the same way that “quirks” mode works. This means that sliced image-in-table layouts are less likely to collapse in browsers in either “quirks” or “almost normal” mode than in “full standards” mode
    3. Full Standard Mode — In this mode, the behaviour described is the same as described by HTML and CSS specifications. Most of the modern browsers use full standard mode. For mre visit — MDN Docs
  4. Will adding any non-executing code, e.g. comments, before the DOCTYPE declaration have any effect?
    Ans — Yes, anything before the DOCTYPE, like a comment or an XML declaration will trigger quirks mode in Internet Explorer 9 and older. That is why DOCTYPE declaration is always at the top, so browser can trigger full standard mode only.

--

--

RanveerSequeira
RanveerSequeira

Written by RanveerSequeira

AI generate Content I like to save as article

No responses yet