HTML chapters

Chapter 2 of 17

Create a complete HTML document

Try this in our HTML Compiler →

The idea

A document has a doctype, a root html element, a head for metadata, and a body for visible content. Set the language and UTF-8 encoding so assistive technology and the browser interpret the text correctly. A page title labels the browser tab; it is not the visible main heading.

Worked example

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Study journal</title>
</head>
<body><h1>My journal</h1><p>Welcome!</p></body>
</html>

What to check

The body appears in the preview. Save the document as index.html when working locally and open it in a browser; no console compiler is needed.

Practice task

Change the tab title and visible heading to different text, then explain what each is for.

Check your understanding

Explain the result in your own words before changing the example. Change one thing at a time, compare the result with your prediction, and keep the version that demonstrates the concept clearly.

Try it yourself

Output
Ctrl/Cmd+Enter runs · Ctrl/Cmd+S downloads the project · Local auto-save is always on