Skip to content
Guest
Learn HTML · Course Syllabus Show lessons
Foundations · 9 min read · Beginner

Document Structure & Metadata

Build a rock-solid HTML document boilerplate with DOCTYPE, lang, charset, viewport, title, and social Open Graph metadata.

What you'll learn

  • Understand why <!DOCTYPE html> and <html lang="en"> are required on every page
  • Configure essential <head> metadata: charset, viewport, title, and description
  • Add favicons and Open Graph tags for rich social sharing previews

Every valid HTML page starts with a small, predictable skeleton. Getting <head> metadata right ensures your site renders crisply on mobile screens, displays emoji and accents cleanly, and looks great in search results and social shares.

The Modern HTML5 Boilerplate

<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Page Title | DevPath</title>
    <meta name="description" content="A concise 150-character summary for search engines." />
    <link rel="icon" href="/favicon.svg" type="image/svg+xml" />
  </head>
  <body>
    <!-- Visible page content goes here -->
  </body>
</html>

What Each Line Does

  • <!doctype html>: Puts the browser into standards mode (avoiding legacy quirks mode).
  • <html lang="en">: Tells screen readers which voice/accent to use and helps search engines and browser translation tools.
  • <meta charset="UTF-8">: Enables full Unicode support (international scripts, punctuation, emoji). Place it as the first tag in <head>.
  • <meta name="viewport" ...>: Prevents mobile browsers from zooming out your page like a tiny desktop screen.

Fill-in-the-Blank Exercise

Complete the HTML Head

Fill in the missing DOCTYPE, character encoding, and page title tag.

<! html>
<html lang="en">
<head>
  <meta ="UTF-8" />
  <>My First Page</title>
</head>
</html>

Try It Yourself: Inspecting Document Metadata

Read Document Metadata via JS
Live Result
Console Output

No console output yet. Try calling console.log(...) in JS.

Check Your Understanding

Score: 0 / 1

1. Why should <html lang="en"> (or your page's language code) always be declared?

Study Workspace

Finished this lesson?

Your progress is saved locally in your browser, no account needed.

Search courses, lessons, and references

Type to search across all courses, lessons, and quick references.

Press Esc to close Powered by Pagefind