sebdeckers / pfnp

:alien: Programming For Non-Programmers
21 stars 14 forks source link

What happens when a page does not have a DOCTYPE? #10

Open sebdeckers opened 9 years ago

sebdeckers commented 9 years ago

Modern documents begin with the HTML 5 doctype declaration:

<!doctype html>

Really old documents did not contain this declaration. Because modern standards can not expect all older documents to be updated, browsers instead assume that any document lacking a doctype declaration is an old document.

Old documents did not render according to the rules of HTML5. There were differences and ambiguities in how HTML, CSS, and JS behaved. So modern browsers switch to a backwards compatible method called "quirks mode" when encountering a page without a doctype.

As a reference, these are the commonly encountered doctype declarations for HTML 4, XHTML, and HTML 5: https://css-tricks.com/snippets/html/the-common-doctypes/