The Doctype Declaration
A free lesson from Swipe Coding · HTML, level 1 · updated October 2026
By the Swipe team, founded by Colin · how we make lessons
Every HTML document starts with a doctype declaration — a single line that tells the browser which version of HTML the page is written in, so it knows how to interpret everything that follows.
<!DOCTYPE html>
Older versions of HTML had long, awkward doctype declarations full of version numbers and URLs. HTML5 simplified this dramatically — the line above is the entire doctype, and it never changes from page to page.
Without a doctype, browsers fall back to something called 'quirks mode,' where they guess at older, inconsistent rendering behavior to stay compatible with very old pages. That's rarely what you want, so the doctype always belongs at the very top of every HTML file, before anything else.
What is the correct HTML5 doctype declaration?
<!DOCTYPE html>
Without a doctype, browsers may fall back to ____ mode, guessing at older rendering behavior.
The doctype declaration should be placed at the very top of an HTML file, before anything else.
Keep your streak going in Swipe Coding
Swipe through every level of HTML on your iPhone — with XP, stars, streaks, a personal advisor and the full track beyond these free levels.
Get the Swipe apps →