The Shape of Every HTML Document

What this is. Every HTML document has the same skeleton. Learn it once and you never have to think about it again.

<!doctype html> tells the browser to use modern standards.

<html> is the root element that contains everything.

<head> holds information about the document: its title, its character encoding, its stylesheets. None of it is displayed on the page.

<body> holds everything the visitor actually sees.

Why the head matters even though it is invisible. The <title> is what appears in the browser tab and in search results. The charset declaration prevents accented characters and quotation marks turning into nonsense. The viewport line is what makes a page usable on a phone, and leaving it out is one of the most common reasons a site looks broken on mobile.

LIVE PREVIEW
loading editor…

Your turn → Change the text inside <title>. Nothing visible happens on the page, because the title belongs to the document rather than to the content. That is the head doing its job.

✦ The lang attribute is not decoration

lang="en" tells a screen reader which language to pronounce, tells the browser which dictionary to use, and tells translation tools what they are working with. It is one attribute and it materially changes who can use your page.

When you write this. Every single time you create a new page. Most editors will generate it for you, but you should be able to type it from memory, because when something is broken you need to recognize what is missing.

◈ Graded Build

Build a complete, valid HTML document for the home page of your portfolio. It needs a doctype, a language of en, a utf-8 charset, a viewport meta tag, a title reading Your Name, and a body containing one h1 and one paragraph.

Checked against the page you actually render, not against how you wrote it. 4 visible and 2 hidden checks.

loading editor…

Mark this lesson complete

Signed in, your progress follows you to every device.

Next: Practice Test →
← Back