Learning Objectives
After completing this tutorial, you will be able to:
- Understand the structure of an HTML document.
- Know the purpose of each main HTML element.
- Read and understand a basic HTML template.
- Build a strong foundation for future HTML lessons.
Table of Contents
- Introduction
- The Complete HTML Template
- Understanding
<!DOCTYPE html> - Understanding
<html> - Understanding
<head> - Understanding
<title> - Understanding
<body> - Real-World Analogy
- Practice Exercise
- Assignment
- Summary
- Frequently Asked Questions
- Next Tutorial
Introduction
Every HTML page follows a standard structure.
Whether you visit a personal portfolio, a business website, or a large platform like YouTube, every page begins with the same basic foundation.
Think of this structure as the blueprint of a house. Before adding furniture, paint, or decorations, the house must have a solid foundation. Similarly, before adding headings, images, or buttons, every web page needs a proper HTML document structure.
Learning this structure now will make every future HTML lesson easier to understand.
The Complete HTML Template
<!DOCTYPE html>
<html>
<head>
<title>My First Website</title>
</head>
<body>
</body>
</html>
Although this template contains only a few lines, each line has an important purpose.
Let's explore them one by one.
Understanding <!DOCTYPE html>
This is the first line of every modern HTML document.
It tells the browser:
"This page uses HTML5."
It is not an HTML tag. It is called a document declaration.
Without it, some browsers may switch to an older compatibility mode, causing your page to behave differently.
Best Practice: Always place <!DOCTYPE html> at the very top of your HTML document.
Understanding <html>
The <html> element is the root element of the page.
Every other HTML element must be placed inside it.
You can think of it as a large container that holds the entire website.
Nothing should exist outside the <html> element except the <!DOCTYPE html> declaration.
Understanding <head>
The <head> section contains information about the web page rather than content shown on the web page.
Inside the <head> element, you'll later add:
- Page title
- Meta description
- Character encoding
- Stylesheets
- Icons
- SEO information
Visitors usually don't see the contents of the <head> directly, but browsers and search engines use this information.
Understanding <title>
The <title> element defines the name of the web page.
This text appears:
- On the browser tab.
- In bookmarks.
- In many search engine results.
Example:
<title>My First Website</title>
If you change it to:
<title>Travel Blog</title>
the browser tab will immediately display Travel Blog after refreshing the page.
Understanding <body>
The <body> element contains everything visitors can actually see on the page.
For example:
- Headings
- Paragraphs
- Images
- Buttons
- Navigation menus
- Videos
- Forms
- Tables
Whenever you create visible content, it will almost always go inside the <body> element.
Real-World Analogy
Imagine you're building a new house.
<!DOCTYPE html>is the building standard that tells everyone which rules you're following.<html>is the entire house.<head>is the electrical wiring, plumbing plans, and architectural drawings—important, but mostly hidden.<title>is the name written on the front gate.<body>is every room where people actually live, work, and interact.
This analogy helps you understand why each part exists and why every one of them is necessary.
Practice Exercise
Answer these questions:
- Which line must always appear first in an HTML document?
- Which element contains the visible content of a webpage?
- Where does the text inside the
<title>tag appear? - What is the purpose of the
<head>element?
Assignment
Open your index.html file.
Change the title from:
<title>My First Website</title>
to your own website name.
Save the file and refresh your browser.
Then answer this question:
What changed after refreshing the page?
Summary
In this tutorial, you learned the five essential parts of every HTML document: <!DOCTYPE html>, <html>, <head>, <title>, and <body>. Together, these elements form the foundation of every web page you will build.
Understanding this structure is one of the most important steps in learning HTML, because every future project in this course will begin with this same template.
Frequently Asked Questions
Can I remove <!DOCTYPE html>?
You can, but it is not recommended. Modern websites should always include it to ensure browsers use the latest HTML standard.
Can a webpage have more than one <body> element?
No. Every HTML document should contain only one <body> element.
Can I put visible text inside the <head> element?
No. Content that visitors should see belongs inside the <body> element.