What is the structure of an HTML document?

Every HTML document starts with <!doctype html>, followed by a root <html lang="..."> element containing two children: <head>, which holds metadata (charset, viewport, title, styles, scripts, SEO tags), and <body>, which holds the visible content, usually organized with landmarks such as <header>, <nav>, <main> and <footer>.

The skeleton

  1. <!doctype html>: puts the browser in standards mode.
  2. <html lang="en">: the root; lang helps screen readers, translation and hyphenation.
  3. <head>:
    • <meta charset="utf-8"> first, within the first 1024 bytes.
    • <meta name="viewport" content="width=device-width, initial-scale=1"> for responsive pages.
    • <title>: required, shown in tabs and search results.
    • <meta name="description">, <link rel="icon">, <link rel="stylesheet">, <script defer>, Open Graph tags.
  4. <body>: everything users see.

Body landmarks

  • <header>: introductory content, logo, site navigation.
  • <nav>: major navigation links.
  • <main>: the primary content; only one visible per page.
  • <aside>: related but secondary content.
  • <footer>: copyright, contact, secondary links.
  • <article> and <section> structure content inside <main>.

Why structure matters

  • Screen reader users jump between landmarks and headings.
  • Search engines understand content better.
  • CSS and JavaScript are easier to write against clear structure.

Good practice

One <h1> describing the page, headings in order (h2 under h1, and so on), and valid nesting (no <div> inside <p>).

Code example

html
1<!doctype html>
2<html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <meta name="viewport" content="width=device-width, initial-scale=1">
6 <title>Blog | Example</title>
7 <meta name="description" content="Articles about modern HTML and CSS.">
8 <link rel="icon" href="/favicon.svg" type="image/svg+xml">
9 <link rel="stylesheet" href="/styles.css">
10 <script src="/app.js" defer></script>
11 </head>
12 <body>
13 <header>
14 <a href="/">Example</a>
15 <nav aria-label="Main"><a href="/blog">Blog</a> <a href="/about">About</a></nav>
16 </header>
17 <main>
18 <h1>Latest articles</h1>
19 <article>
20 <h2>Container queries in practice</h2>
21 <p>Components that adapt to their container, not the viewport.</p>
22 </article>
23 </main>
24 <aside>Popular tags</aside>
25 <footer>&copy; 2026 Example</footer>
26 </body>
27</html>

Practice this question

Open it in the study app to track progress, take notes, listen to the answer and work through the rest of the HTML & CSS set.

Open in study app