Swipe
SwipeSwipe
Swipe Apps

Paths

Motivation

Information

The Shape of an HTML Document · Lesson 5 of 18

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>
The complete HTML5 doctype — short, and always exactly this line.
🤖
Older doctypes were long, ugly, and easy to typo. HTML5 fixed that. 🎉

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.

Quick check

What is the correct HTML5 doctype declaration?

<!DOCTYPE html>
Fill in the blank

Without a doctype, browsers may fall back to ____ mode, guessing at older rendering behavior.

True or false

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 →