Your Page Title
🔍

    HTML <!DOCTYPE> Tag

    What Does <!DOCTYPE> Do?

    The recognizability of <!DOCTYPE> is a declaration that notifies your browser as to what version of HTML your page is being written in. The tags themselves help guide the browser on how to interpret/ read the content that is put before it.

    What you registered is like saying to the browser, “Holla! I am using that version of HTML, so just style my page accordingly.”

    Modern versions of this declaration are what we use for HTML5, such as this:

    <!DOCTYPE html>

    That is about it. Quite simple, one would say. But this small tag defines a big impact. If you forget to tell your browser, or have the wrong version, your page may not be rendered correctly, or it may automatically fall back to outdated rendering methods.

    What Is the Big Deal?

    Without the proper declaration, browsers might go into a mode called “quirks mode.” Quirks mode is basically an old web standards fallback, wherein the browsers are trying to render pages in the same manner as it was in the past. While that might have worked for the websites of the 1990s, it doesn’t fit well with modern standards for HTML and CSS.

    When your browser runs your page in quirks mode, you’ll notice some strange situations, such as:

    • Layout problems (things not lining up properly)
    • Inconsistent font sizes or text formatting
    • Incorrect spacing between elements
    • Unpredictable behavior of modern CSS features, like flexbox or grid

    The declaration does just this-makes sure those messes never arise, by telling the browser to use the current HTML standard (HTML5) to ensure your page looks right and works as it should.

    The History Of <!DOCTYPE>

    The <!DOCTYPE> tag is not something that is newer. It has been around quite some time. Back in the day when the standard of HTML was being formulated, various versions of the language (HTML 4, XHTML, etc.) required various declarations for . Each version of HTML had its own rules.