Getting Started Lesson 3 of 42
The Basic Structure of an HTML Page
Understand the parts every HTML page needs — doctype, html, head and body — and how tags are nested inside each other like boxes.
Every HTML page, from a one-line school project to a big online shop, follows the same basic skeleton. Once you know it by heart, you can start any page in seconds. In this lesson we will look at each part of that skeleton and explain why it is there.
The skeleton
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Page Title</title>
</head>
<body>
<h1>My Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
Part 1: the doctype
<!DOCTYPE html> is always the very first line. It is not a tag that shows anything. It is a short note that says "please read this page using modern HTML rules." Without it, browsers switch to an old "quirks mode" made for websites from the 1990s, and your page can look slightly wrong.
Part 2: the html element
The <html> element wraps everything else. It is called the root element. The lang="en" part tells browsers, screen readers and Google that the page is written in English. If your page is in Filipino, you can use lang="fil". (That lang part is called an attribute. You will learn about attributes soon.)
Part 3: the head
The <head> holds information about the page — called metadata. Visitors mostly do not see it, but browsers and search engines do. In the starter template:
<meta charset="utf-8">lets your page show every kind of character correctly: ñ, é, ₱, and even emoji. Without it, a word like "Parañaque" may appear as strange symbols.<meta name="viewport" ...>makes the page fit nicely on phone screens. Leave it out and your page will look tiny on mobile.<title>sets the text on the browser tab.
Part 4: the body
The <body> holds everything visible: headings, paragraphs, images, links, tables, forms and videos. Almost all of your work happens here. There is only one body on a page.
Nesting: boxes inside boxes
Look at the template again. The <title> is inside <head>, and <head> is inside <html>. Putting elements inside other elements is called nesting. It works like a pasalubong box: the big box holds smaller boxes, and each small box holds the actual goodies.
We describe these relationships like a family:
<html>is the parent of<head>and<body>.<head>and<body>are children of<html>, and they are siblings of each other.<h1>and<p>are children of<body>.
These family words are used a lot in CSS and JavaScript later, so it's good to learn them now.
Indentation makes code readable
Notice how the lines inside <head> and <body> are pushed to the right with spaces. That is called indentation. Browsers ignore it, but humans need it. When your page grows to hundreds of lines, indentation shows you at a glance which element is inside which. Most developers use 2 spaces per level.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Class Schedule</title>
</head>
<body>
<h1>Grade 10 – Rizal</h1>
<p>Monday: Math, Science, English</p>
<p>Tuesday: Filipino, AP, TLE</p>
</body>
</html>
The page works the same, but the code is harder to follow. Get into the habit of indenting now. In VS Code, you can press Shift + Alt + F to format the file automatically.
Whitespace is collapsed
Here is something that surprises beginners: if you press Enter ten times or type ten spaces in your HTML, the browser shows only one space. This is called whitespace collapsing. To control how things are spaced, you use proper tags (like paragraphs and line breaks) and, later, CSS.
<p>Mabuhay! Welcome to our school.</p>
<p>This line
has many line breaks in the code, but shows as one line.</p>
Quick Quiz
Check what you learned. Walang grade ito, practice lang. 🙂
By Sir Reyel · Last updated 2026-12-04