Banner for switzCodes blog post titled 'Banner for switzCodes blog post titled 'Understanding the HTML Document Structure (<!DOCTYPE html> to <body>) - Building
                        the Foundation of Every Web Page' featuring modern geometric design in dark blue, white, and green 📄 Understanding the HTML Document Structure (<!DOCTYPE html> to <body>) - Building the Foundation of Every Web Page

📅 August 8, 2025

✍️ By Evans

Hey again! 👋

After getting my hands dirty with basic HTML, I started wondering what all those tags like <!DOCTYPE html>, <html>, <head>, and <body> actually mean. I saw them in every HTML file, but didn't really know why they were there.

So in this post, I'm gonna break down the basic HTML document structure — each part does and why it's important.

🏗️ The Basic Skeleton of an HTML Page

Here's a simple HTML page structure I've been practicing with:

<!DOCTYPE html>
<html>
  <head>
    <title>My Web Page</title>
  </head>
  <body>
    <h1>Hello, World!</h1>
    <p>This is a simple HTML document structure.</p>
  </body>
</html>

Let me explain each part in plain English 👇

  1. <!DOCTYPE html>
  2. This line goes at the very top of every HTML document.

    It's not an HTML tag — it just tells the browser:

    “Hey, this is an HTML5 document!”

    Without this, browsers might guess or switch into “quirks mode”, which can break your layout. So always include it. ✅

  3. <html> ... </html>
  4. This is the root element of your web page.

    Everything you want to show (or set up) on the page goes inside these two tags.

    It's like the big box that holds your whole page together.

  5. <head> ... </head>
  6. This part doesn't show up on the webpage, but it sets up important background stuff.

    Here's what you usually put inside the <head>:

    • <title> What shows in the browser tab
    • Meta tags - Info about your site (like description, keywords, etc.)
    • Links to CSS files or fonts
    • Favicon (the little icon in the tab)

    Example:

    <!DOCTYPE html>
      <head>
        <title>My Web Page</title>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
      </head>
      
    
    

💬 Some Random Beginner Tips That Helped Me

  • Always close your tags (like <p></p>). Trust me, I forgot a lot at first 😅
  • Save your files with .html at the end, like index.html
  • Use a browser to open your file and see what you built
  • VS Code makes life easier as a beginner

🎯 Why I'm Loving This

Learning HTML gave me that “Whoa, I actually made this!” feeling. It's not flashy like animations or JavaScript (yet), but it's the foundation of everything on the web. And now I finally understand how websites are built from scratch.

This post is just the start. I'll be learning CSS and JavaScript soon, but for now, I'm focusing on getting my HTML basics solid.

👉 What's Next?

In my next blog post, I'll talk about the HTML structure and explain how all the parts of a webpage are organized. I'll try to break it down in a simple way, just like I'm learning it.

Thanks for stopping by and reading my first post. If you're also learning HTML, let's grow together! 🙌

Catch you in the next one!

— Evans 💻