Skip to content

HTML Tutorial Getting Started

HTML Page Structure: Doctype, Head and Body Explained

Lesson 4 of 81 2 min read By Deepak Paswan Updated Oct 4, 2026

Every HTML page, from a one-line test to a huge shop, shares the same skeleton. Once you know it, you can read almost any page.

index.html
HTML
<!DOCTYPE html>
<html lang="en">
  <head>
    <!-- information about the page -->
  </head>
  <body>
    <!-- the visible page -->
  </body>
</html>

The doctype

The first line, <!DOCTYPE html>, tells the browser to read the page using modern rules. Without it, browsers fall back to an old “quirks mode” that renders some things differently. The doctype is not a tag and it is not case sensitive, but you should always include it.

The html element

<html> is the root element. Every other element lives inside it. Put the lang attribute here. It tells screen readers which language to pronounce, and helps browsers offer translation.

The head: information about the page

Things inside <head> are not shown as part of the page. The most common are:

ElementPurpose
<meta charset="UTF-8">The character encoding, so text displays correctly
<title>The page title, shown in tabs and search results
<meta name="viewport" ...>Makes the page behave on phones
<meta name="description" ...>A summary search engines may show
<link rel="stylesheet" ...>Loads a CSS file

The body: what visitors see

Everything people can read, click or watch goes inside <body>. You will spend most of your time here.

index.html
HTML
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <title>Opening hours | Juniper Books</title>
</head>
<body>
  <h1>Opening hours</h1>
  <p>Monday to Saturday, 9:00 to 18:00.</p>
</body>
</html>
warning
Putting visible content in the head
Text placed inside <head> can behave strangely or be moved by the browser. Keep the head for page information and the body for page content.
lightbulb
Indent nested code
Indent each nested level by two spaces. It does not change how the page works, but it makes the structure easy to see and mistakes easy to spot.

You now know the skeleton. In the next chapter you will meet the building blocks that go inside it, starting with HTML Elements.