Module 2 of 12

📖 The HTML Document Skeleton

Every valid HTML document follows a specific structure. Think of it like a formal letter — it has required parts that must appear in a specific order.

The Complete Document Template

<!-- This is the complete HTML5 document structure --> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Page Title Here</title> </head> <body> <!-- All visible content goes here --> </body> </html>

Breaking Down Each Part

ElementPurposeRequired?
<!DOCTYPE html> Tells the browser this is an HTML5 document Yes
<html> The root element that wraps everything Yes
lang="en" Declares the page language (helps screen readers & SEO) Recommended
<head> Contains metadata (information about the document) Yes
<meta charset="UTF-8"> Sets character encoding to support all languages Yes
<meta viewport> Makes the page responsive on mobile devices Yes
<title> Sets the browser tab title Yes
<body> Contains all visible content Yes
⚠️ Common Mistake: Never put visible content inside the <head>. Only metadata goes there. All text, images, and elements users see must be inside <body>.

📋 Understanding DOCTYPE

The <!DOCTYPE html> declaration is the very first line of every HTML5 document. It is not an HTML tag — it's an instruction to the browser.

Why DOCTYPE Matters

Browsers have two modes:

Without a DOCTYPE, browsers switch to Quirks Mode, and your page may look broken or behave unexpectedly.

HTML5 vs. Older Versions

In older HTML versions, DOCTYPE was long and complicated:

<!-- HTML 4.01 DOCTYPE (old and complex) --> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <!-- HTML5 DOCTYPE (simple and clean) --> <!DOCTYPE html>
💡 Remember: HTML5 simplified everything. Just write <!DOCTYPE html> and you're good to go!

🔍 The <head> Section Deep Dive

The <head> contains invisible but essential information. Let's explore the most important elements.

Character Encoding (Critical!)

<meta charset="UTF-8">

UTF-8 supports every character in every human language — including Amharic, Arabic, Chinese, emojis, and special symbols. Always include this as the first meta tag.

Viewport Meta Tag (Mobile Essential)

<meta name="viewport" content="width=device-width, initial-scale=1.0">

This tag ensures your website looks good on phones and tablets. Without it, mobile browsers might zoom out and show a tiny, unreadable version of your desktop layout.

Description Meta Tag (SEO)

<meta name="description" content="Learn HTML from scratch with Ethioweb.net's free beginner course.">

This appears in Google search results under your page title. Keep it under 160 characters and make it compelling!

Author Meta Tag

<meta name="author" content="Your Name">

Favicon (Browser Tab Icon)

<link rel="icon" type="image/x-icon" href="favicon.ico">

The tiny icon that appears in browser tabs and bookmarks. You can also use PNG or SVG formats.

Complete Head Example

<head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content="Learn HTML with Ethioweb.net"> <meta name="author" content="Ethioweb.net"> <title>HTML Course - Ethioweb.net</title> <link rel="stylesheet" href="style.css"> <link rel="icon" href="favicon.ico"> </head>

✏️ Exercise 2.1: Build a Perfect Document Skeleton

Your Task

Create a new file called skeleton.html with the following requirements:

  1. Correct HTML5 DOCTYPE declaration
  2. <html> tag with lang="en"
  3. A <head> containing:
    • UTF-8 charset meta tag
    • Viewport meta tag
    • Description meta tag about yourself
    • Author meta tag with your name
    • A meaningful <title>
  4. A <body> containing:
    • An <h1> with your name
    • A <p> introducing yourself

Validation Check

After creating your file, validate it using the W3C Markup Validation Service. A valid document should show "Document checking completed. No errors or warnings to show."

📝 Module 2 Quiz

Test Your Knowledge
1. What is the purpose of <!DOCTYPE html>?
2. Which meta tag is essential for mobile responsiveness?
3. Where does all visible page content belong?
4. What does UTF-8 support?
5. What does the <title> tag set?

🎯 Module Summary

← Previous Module Next: Module 3 →