Skip to content
FORGENO ADS GAMESUnlock all $8

HTML · Unit 2: Images and page structure · Lesson 5 of 5

A complete page

A complete HTML file starts with <!doctype html>, which tells the browser to use modern rules.

Opens this lesson in Code Academy. Lessons open one after another, and each unit opens when you pass the checkpoint quiz before it (you can take a checkpoint early to skip ahead). If this lesson is not open yet, the button shows you its unit on your map.

The idea

A complete HTML file starts with <!doctype html>, which tells the browser to use modern rules. Everything else goes inside <html lang="en">; lang tells screen readers which language to speak.

<head> holds information about the page: <meta charset="utf-8"> so every letter and emoji shows correctly, a viewport <meta> so phones size the page properly, and <title> for the browser tab.

<body> holds everything people see. Comments like <!-- note --> are notes for people reading the code; the browser ignores them.

Worked example

HTML

<!doctype html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Trail Guide</title>
  </head>
  <body>
    <!-- Main content goes here -->
    <h1>Trail Guide</h1>
  </body>
</html>

Every page you build from now on can start from this outline.

Key terms

Doctype and head
<!doctype html> starts every page; <head> holds the charset, the viewport and the <title>.
Comment
A note for people reading the code, like <!-- note --> in HTML or // note in JavaScript.

Practise it in Code Academy

It has 4 exercises (multiple choice, fill in the blank and write code from a prompt) and takes about 7 minutes. Every answer is checked as you go, and feedback names the exact mistake. Hints and the solution are there if you get stuck.

Every lesson is free: no ads, no lives and no paywall.