The basic HTML document
Covered here
- The HTML boilerplate, line by line
- Why every page needs the same skeleton
- Indentation for readable code
- HTML comments for notes
Short answer
Every HTML page uses the same skeleton, often called the boilerplate or starter template. It has a doctype, an <html> root element, a <head> for information about the page, and a <body> for what visitors see. Copy it once, and you will reuse it for every page you build.
The HTML boilerplate
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Page title</title>
</head>
<body>
<h1>Page heading</h1>
<p>Page content goes here.</p>
</body>
</html>
Only about ten lines, but each one has a job. You will study each part in Lesson 2.2.
Head vs body
| Part | Holds | Visible on the page? |
|---|---|---|
| <head> | Title, character encoding, metadata, links to CSS | No |
| <body> | Headings, text, images, links, forms | Yes |
A simple way to remember: the head is the page’s brain, full of information. The body is the part people see.
Indentation keeps code readable
Browsers ignore extra spaces and line breaks in your code. Indentation is for humans. Indent each child element two spaces inside its parent so you can see the tree at a glance.
<body>
<ul>
<li>Pili nuts</li>
<li>Abaca bags</li>
</ul>
</body>
Comments are notes for you
Text between <!-- and --> is a comment. The browser hides it. Use comments to leave notes for yourself or your team.
<!-- Contact section starts here -->
Comments are still visible in View page source, so never put passwords or private notes in them.
Try it: fill the skeleton
The skeleton is empty. Put a heading and two paragraphs inside the body. Then add a comment that says where the content starts.
Live preview
Quick quiz
Common mistakes
- Putting content in the head. Headings and paragraphs belong in the body.
- Two body elements. A page has exactly one head and one body.
- Secrets in comments. Anyone can read comments in the source code.
Your action
Tick each item when you can do it. Your progress saves on this device.
Key terms
- Boilerplate
- A standard starter template reused on every page.
- <head>
- The container for information about the page.
- <body>
- The container for everything visitors see.
- Indentation
- Spaces at the start of a line that show nesting.
- HTML comment
- A hidden note written between <!-- and -->.
Questions beginners ask
Do I have to type the boilerplate every time?
No. Save it as a template, or type ! and Tab in VS Code.
What if I forget the head?
Browsers will add one, but your page may lose its title and character encoding. Always include it.
Tabs or spaces?
Either works. Two spaces is the most common style for HTML.
Related lessons
Need a website built or fixed while you practice? The team at Remar Digital can help.