MGU Computer Science Series — Web Development: HTML, CSS, and JavaScript
Part II: HTML — Structure and Meaning
Documents · Elements · Attributes · Structure
Chapter 5 of 30
5
MGU Computer Science Series  ·  Web Development: HTML, CSS, and JavaScript  ·  Library Textbook Edition

Chapter 5:
HTML Documents and
Page Structure

Elements, tags, attributes, nesting, and the document skeleton that every web page is built upon

■ Part II of VII ■

■ 10 Sections  •  Chapter 5 of 30 ■

Gateway chapter to HTML — no prior web development experience required

Chapter Introduction and Learning Objectives

Every website begins with an HTML document. Before a browser can display text, images, links, or any other content, it needs a correctly structured file that tells it what kind of document it is reading and how that document is organized. In Part I, you learned how the web works as a system — clients, servers, requests, and responses. Now it is time to write the actual documents that browsers request and display.

This chapter introduces HTML: what it is, how it works, and how to write a valid, well-structured HTML page from scratch. You will learn the vocabulary of elements, tags, and attributes; the rules of nesting and indentation; and the required skeleton that every HTML document must follow. By the end of this chapter, you will understand every part of the basic HTML document skeleton and be able to write a clean starter page that a browser can interpret correctly.

Opening Question

Two students each write a web page. One forgets a single closing tag. The other writes every tag correctly but never declares a document type. Both pages "sort of work" when opened in a browser — but neither behaves entirely as intended, and neither would pass a professional code review. What is actually happening inside the browser when it reads a file like this? What rules is HTML following, and what happens when those rules are broken? By the end of this chapter, you will be able to answer both questions — and avoid both students' mistakes.

10Sections
11Objectives
20Key Terms
30Total Chapters

Learning Objectives

By the end of this chapter, you should be able to:

  1. 1Explain what HTML is and describe its role alongside CSS and JavaScript.
  2. 2Identify the parts of an HTML element: the opening tag, the content, and the closing tag.
  3. 3Distinguish void (self-closing) elements from elements that require closing tags.
  4. 4Write and use attributes correctly within an opening tag, including boolean attributes.
  5. 5Explain nesting and apply consistent indentation to reflect a document's structure.
  6. 6Reproduce the basic HTML document skeleton from memory.
  7. 7Explain the purpose of the DOCTYPE declaration and the difference between standards mode and quirks mode.
  8. 8Distinguish the roles of the html, head, and body elements, including the purpose of the lang attribute.
  9. 9Explain the purpose of the title element and write descriptive, well-formed page titles.
  10. 10Write a complete, valid HTML starter page from scratch and save it with the correct file extension.
  11. 11Identify and correct common HTML errors, including missing closing tags, overlapping elements, and missing attributes.

Sections at a Glance

Sections 5.1 – 5.3
The Building Blocks: HTML, Elements, and Tags
Markup Language · Elements · Opening and Closing Tags

What HTML Is

When you visit a website, your browser receives a file from a server. That file is almost always an HTML file. HTML stands for HyperText Markup Language. It is the foundational language of the web.

HTML is not a programming language. It does not make decisions, run calculations, or respond to user actions on its own. HTML is a markup language: it uses a set of structured labels, called tags, to describe the meaning and organization of content. Those labels tell the browser things like "this is a heading," "this is a paragraph," "this is a link," or "this is an image." The browser reads those labels and uses them to build a visual page on the screen. Without HTML, the browser has no way to know what anything means or how anything should be organized.

The "H"
HyperText
Text that contains links to other documents. Clicking a link and traveling to a new page is navigating through HyperText — the idea of connecting documents together that defines the web.
The "M"
Markup
A term borrowed from publishing, where editors annotated manuscripts with instructions. In HTML, content is annotated with tags that give it meaning, such as marking text as a heading.
The "L"
Language
A defined grammar and vocabulary that browsers understand and use to interpret files. Follow the grammar and your page renders as intended; break it and the browser may interpret things differently than you expect.
What HTML Is Not

HTML does not control visual appearance — that is the job of CSS. HTML does not add interaction, animation, or behavior — that is the job of JavaScript. HTML does not store or process data — that is the job of servers and databases. HTML structures content and gives it meaning. That is its job, and it does that job very well.

Elements and Tags

The building blocks of HTML are called elements. An element represents a piece of content and the meaning assigned to it. A heading is an element. A paragraph is an element. A link is an element. An image is an element.

Most HTML elements have three parts: an opening tag, the content inside the element, and a closing tag. A tag is the actual text you write to mark the beginning or end of an element, written inside angle brackets.

Anatomy of an Element
Opening tag → content → closing tag
<p>This is a paragraph of text.</p>
  • Opening tag<p> — marks the start of a paragraph element. "p" stands for paragraph.
  • Content"This is a paragraph of text." — the text the element wraps around.
  • Closing tag</p> — marks the end of the element, using a forward slash before the element name.
Convention: Always Use Lowercase

HTML element names are technically not case-sensitive — <P> and <p> are interpreted the same way. However, modern HTML standards and professional convention both use lowercase element names. Always write <p>, never <P>.

Void (Self-Closing) Elements

Most HTML elements have both an opening and a closing tag. Some elements, however, do not have content inside them — they insert something into the page rather than wrapping around text. These are called void elements.

Void ElementWhat It Inserts
<img>An image
<br>A line break
<hr>A horizontal rule
<input>A form input field
<link>A link to an external resource, such as a CSS file
<meta>Metadata about the document

You may sometimes see void elements written with a trailing slash, such as <img /> or <br />. This was required in an older version of HTML called XHTML. In modern HTML5, the trailing slash is optional and not required.

Opening Tags and Closing Tags

Understanding opening tags and closing tags clearly will save you many hours of debugging. An opening tag marks the beginning of an element: a less-than sign, the element name, and a greater-than sign — for example, <h1>, <ul>, or <section>. It tells the browser, "Start treating content as this type of element here."

A closing tag marks the end of an element: a less-than sign, a forward slash, the element name, and a greater-than sign — for example, </h1>, </ul>, or </section>. It tells the browser, "This element ends here."

Example 5.3.1
Complete elements: opening tag, content, closing tag
<h1>Chapter 5: HTML Documents and Page Structure</h1> <p>HTML is the foundational language of the web.</p>
Common Mistake

One of the most common beginner HTML mistakes is forgetting to write a closing tag. When a closing tag is missing, the browser attempts to recover — but the result may not be what you intended.

<!-- Incorrect: missing closing tag --> <p>This paragraph never ends. <p>This is a new paragraph, but the browser may be confused about the first one. <!-- Correct --> <p>This paragraph ends properly.</p> <p>This is a separate paragraph.</p>
Study Habit

Always write your closing tag immediately after your opening tag, before writing the content in between. This habit prevents forgetting the closing tag entirely.

Sections 5.4 – 5.6
Adding Detail and Structure: Attributes, Nesting, and the Skeleton
Attributes · Parent and Child Elements · Indentation · Document Skeleton

Attributes

Many HTML elements accept additional information called attributes. Attributes provide details about an element — details that modify how it works or what it refers to. Attributes are always written inside the opening tag, never in the closing tag. An attribute has two parts: a name and a value, separated by an equals sign, with the value wrapped in quotation marks.

<element attribute-name="attribute-value">

For example, the <a> element creates a link. But a link is useless without knowing where it goes. The href attribute provides the destination:

<a href="https://example.com">Visit Example</a>

An element can have more than one attribute, separated by spaces inside the opening tag:

<img src="dog.jpg" alt="A golden retriever sitting in a park" width="400" height="300">
Reading the Example Above
Four attributes on one img element
  • srcThe file path to the image.
  • altAlternative text describing the image, used by screen readers and shown if the image fails to load.
  • widthThe display width, in pixels.
  • heightThe display height, in pixels.
Always Use Double Quotation Marks

Attribute values should always be wrapped in double quotation marks: href="https://example.com". Single quotation marks work technically, but double quotation marks are the universal standard in HTML.

Boolean Attributes

Some attributes do not need a value — their presence alone signals something to the browser. These are called boolean attributes, such as checked, required, and disabled.

Writing the attribute name is enough. You do not need to write required="true", though some developers do write the value explicitly for clarity.

<input type="checkbox" checked> <input type="text" required> <button disabled>Cannot Click</button>

Nesting and Indentation

HTML elements can contain other HTML elements. When one element lives inside another, this is called nesting. Nesting is fundamental to HTML — almost every page you write will have deeply nested structures. A list contains list items. A section contains paragraphs and headings. A navigation menu contains links.

<ul> <li>Home</li> <li>About</li> <li>Contact</li> </ul>

Here, three <li> (list item) elements are nested inside a <ul> (unordered list) element. The <ul> is called the parent element. The <li> elements are called child elements.

The Critical Rule of Nesting

When you nest elements, the inner element must be completely inside the outer element. Overlapping elements — where an inner element starts inside an outer element but closes outside it — is invalid HTML. Think of nested elements as boxes inside boxes. A small box must be entirely inside the large box; it cannot stick out through the wall.

<!-- Correct: em is completely inside p --> <p>This is <em>very important</em> information.</p> <!-- Incorrect: elements overlap --> <p>This is <em>very important</p> information.</em>

Indentation

Indentation means adding spaces (or tabs) at the beginning of lines to show the nesting structure of your HTML. Well-indented HTML is far easier to read and debug. The standard indentation in HTML is two spaces per nesting level. Some developers use four spaces; some use tabs. Choose one style and be consistent throughout your project.

<body> <main> <section> <h1>Main Heading</h1> <p>This paragraph is inside a section, inside main, inside body.</p> </section> </main> </body>
Indentation Does Not Change Meaning — But It Changes Everything Else

The browser ignores extra whitespace, so indentation does not change how a page renders. But it dramatically improves readability for humans, including you when you return to your code later. A child element should be indented one level more than its parent, and a closing tag should line up with its matching opening tag.

The HTML Document Skeleton

A valid HTML document is not just a collection of elements. It has a required structure. Every HTML file you write should follow this skeleton:

The Minimum Valid HTML Document
Every part matters — the rest of this chapter explains each one
<!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> <!-- Page content goes here --> </body> </html>
Sections 5.7 – 5.10
Assembling the Document: DOCTYPE, html, head, body, and title
Standards Mode · Root Element · Metadata · Visible Content · The Starter Page

<!DOCTYPE html> and Standards Mode

The very first line of every HTML file should be the document type declaration: <!DOCTYPE html>. This line tells the browser which version of HTML you are using. It is the declaration for HTML5, the current version of HTML, and it is written before the opening <html> tag — it is not itself an HTML element.

Why the DOCTYPE Matters

Web browsers have been handling HTML files for decades, across many versions of HTML. If a browser cannot tell what kind of document it is reading, it may switch into a compatibility mode called quirks mode, which changes how it renders the page — sometimes dramatically.

Writing <!DOCTYPE html> at the top of your file tells the browser: "This is a modern HTML5 document. Use current web standards to interpret it." This is called standards mode.

Always First, Nothing Before It

Always include the DOCTYPE declaration, and always write it on the first line. Never write anything before it — not even a blank line — because some browsers may interpret a preceding blank line as an absent DOCTYPE.

The html, head, and body Elements

Immediately after the DOCTYPE declaration, the html element begins. It wraps the entire document and is called the root element because it is the outermost element of every HTML document. Everything else lives inside it.

<!DOCTYPE html> <html lang="en"> <!-- All document content lives inside here --> </html>
The lang Attribute Is an Accessibility Requirement

The lang="en" attribute declares the document's primary language. Screen readers use it to apply correct pronunciation rules; search engines use it to index content by language; browsers may use it for hyphenation and typography. Always include lang on your html element — it is not an optional decoration.

Inside the html element, there are two direct children: head and body.

ElementWhat It HoldsVisible on the Page?
<head>Page title, character encoding, viewport settings, links to CSS and JavaScript files, meta descriptions, social sharing informationNo — metadata only
<body>Headings, paragraphs, images, links, navigation menus, forms, and every other piece of visible contentYes — everything seen on screen

None of the information inside head appears directly in the visible content area of the browser window. Everything you can see when you load a web page comes from what is inside the body element.

The title Element

The title element lives inside head and sets the title of the page. This title appears in the browser tab, in the browser's history list, in bookmarks, and in search engine results.

<head> <title>About Us — Maple Grove School</title> </head>
Writing Good Page Titles
Four qualities of an effective title
  • DescriptiveIt clearly tells the user what the page is about.
  • ConciseIt fits comfortably in a browser tab. Titles longer than about 60 characters may be truncated by search engines.
  • UniqueEach page of a website should have a different title — not "Page" repeated everywhere.
  • Formatted logicallyA common convention places the page name first, then the site name: Page Name — Site Name.
title Is Not the Same as h1

The title element sets the browser tab title. It does not add a visible heading to the page content itself — that comes from heading elements like <h1>, which you will study in Chapter 6. Many beginners confuse these two: title lives in head and is invisible on the page; h1 lives in body and is visible as a large heading.

Writing a Valid Starter Page

Now that you understand every part of the HTML document skeleton, you can write a complete, valid HTML page. Here is a full starter page with meaningful content:

<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>My First Web Page — Learning HTML</title> </head> <body> <h1>My First Web Page</h1> <p>Welcome to my first HTML page. I am learning web development.</p> <p>HTML gives structure and meaning to content on the web.</p> </body> </html>
Tracing the Document Line by Line
What every line tells the browser
  • Line 1<!DOCTYPE html> — this is an HTML5 document; use standards mode.
  • Line 2<html lang="en"> — the root element begins; the language is declared as English.
  • Line 4<meta charset="UTF-8"> — declares character encoding. UTF-8 supports virtually all languages and symbols on earth, and should be the first thing inside head.
  • Line 5<meta name="viewport" ...> — sets up responsive behavior so the page displays correctly on phones and tablets. Studied in depth in Chapter 17.
  • Line 6<title>...</title> — sets the text that appears in the browser tab.
  • Line 9<h1>...</h1> — a top-level heading, visible on the page.
  • Lines 10–11Two paragraphs of visible text content.
Saving Your File

HTML files must be saved with the .html file extension. Your browser reads this extension to know it should interpret the file as HTML. The main file of any web project is almost always named index.html — when a browser or server loads a folder without specifying a filename, it automatically looks for index.html. You will learn much more about this convention in the project structure chapters.

Worked Example: Building the Starter Page Step by Step

This worked example walks through building a valid HTML page for a fictional school club, explaining each decision along the way. The goal: build a complete, valid HTML page for a "Film Club" with a correct DOCTYPE and language declaration, a clear title, a visible heading, and two paragraphs of content.

Worked Example 5.10.1
From an empty file to a finished, valid page
  • Step 1Create a new file in your project folder and name it index.html.
  • Step 2Type the DOCTYPE declaration on the first line, with nothing before it — not a blank line, not a comment, nothing.
  • Step 3Add the <html lang="en"> element right away. The lang attribute is easy to forget later, so include it immediately.
  • Step 4Add empty <head> and <body> elements at the same time, even though both are empty — this prevents the common mistake of forgetting one of them.
  • Step 5Add essential head metadata in order: charset first, viewport second, title third.
  • Step 6Add content to body: a heading and two paragraphs about Film Club.
  • Step 7Save the file and open it in a browser to check the result.
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Film Club — MGU School</title> </head> <body> <h1>Welcome to Film Club</h1> <p>Film Club meets every Thursday at 3:30 PM in Room 214. All students are welcome.</p> <p>This term we are studying classic science fiction films from the 1950s to the 1980s.</p> </body> </html>
Checking the Result

Open the saved file in a browser. You should see "Film Club — MGU School" in the browser tab, a large heading reading "Welcome to Film Club," and two paragraphs of text below it. No styling yet — the page uses only the browser's default appearance. CSS arrives in Part III.

Chapter Summary

Key Terms

HTML
HyperText Markup Language — the markup language used to structure and give meaning to content on the web.
element
A unit of HTML content defined by an opening tag, optional content, and a closing tag.
tag
The text written in angle brackets that marks the start or end of an HTML element.
opening tag
The tag that marks the beginning of an element, written as <elementname>.
closing tag
The tag that marks the end of an element, written as </elementname>.
void element
An HTML element that has no content and therefore no closing tag, such as img, br, and meta.
attribute
Additional information written inside an opening tag, consisting of a name and a quoted value, such as lang="en".
boolean attribute
An attribute whose presence alone signals something to the browser, such as checked, required, or disabled.
nesting
Placing one HTML element inside another. Nested elements must not overlap.
indentation
Adding consistent spaces or tabs at the start of lines to visually reflect the nesting structure of HTML.
DOCTYPE declaration
The <!DOCTYPE html> statement that must appear on the first line of every HTML file, triggering HTML5 standards mode.
standards mode
The browser rendering mode triggered by a correct DOCTYPE, in which the browser follows current web standards.
quirks mode
An older browser rendering mode used when a document's standards compliance cannot be confirmed. Produces inconsistent results.
root element
The html element, which wraps the entire HTML document.
head element
The HTML section that contains metadata — information about the page not directly visible to users.
body element
The HTML section that contains all visible page content.
title element
An element inside head that sets the text shown in the browser tab, bookmarks, and search engine results.
character encoding
The system used to represent text characters in a file. UTF-8 is the web standard and supports nearly all languages and symbols.
metadata
Information about a document — language, encoding, title, viewport settings — placed in head and not directly visible on the page.
lang attribute
The attribute on the html element that declares the document's primary language, important for accessibility and search engines.

Concept Check

Answer these questions before beginning the full review questions. They check basic understanding, not deep analysis.

  1. In your own words, what is an HTML element, and what are its three parts?
  2. Why do void elements such as img and br have no closing tag?
  3. What is the difference between an attribute name and an attribute value? Give one example.
  4. What does it mean for two elements to overlap, and why is that invalid?
  5. What is the very first line of every valid HTML file, and why does its position matter?
  6. What is the difference between what belongs in head and what belongs in body?
  7. What is the difference between the title element and an h1 heading?

Common Misconceptions

Misconception 1
"The DOCTYPE declaration doesn't matter much, so it can go anywhere near the top of the file."
The DOCTYPE must be the very first thing in the file, with absolutely nothing before it — not even a blank line or a comment. If the browser cannot confirm the document type immediately, it may fall back into quirks mode, an older rendering mode that produces inconsistent results.
Misconception 2
"Since lang is just for translation, it can be skipped if my page is written in English."
The lang attribute is not a translation tool — it is an accessibility and standards requirement. Screen readers use it to apply correct pronunciation rules, and search engines use it to index content correctly, regardless of which language the page is written in. Always include lang="en" (or the appropriate language code) on the html element.
Misconception 3
"It's fine to put a heading or a paragraph inside head, since head means the top of the page."
head does not mean "the top of the visible page" — it means "metadata about the document." Visible content such as headings and paragraphs belongs inside body. When content is mistakenly placed inside head, browsers typically move it into body automatically, but the document structure remains invalid and confusing to read.
Misconception 4
"If I forget a closing tag, the browser will just figure out what I meant, so it doesn't really matter."
Browsers do attempt to recover from missing closing tags, but the result is often not what was intended — later elements may end up nested incorrectly, or styling and scripting may behave unpredictably. Every element that has content should be opened and closed with matching tags.
Misconception 5
"Nesting order doesn't matter as long as every tag eventually gets closed somewhere."
Elements must close in the reverse order they were opened, and an inner element must close before its outer element does. Closing tags out of order — so that elements overlap rather than nest cleanly — produces invalid HTML even if every tag is technically present.
Misconception 6
"Attribute values work fine without quotation marks as long as there are no spaces in them."
While some browsers may render unquoted attribute values without spaces, this is not standards-compliant HTML and can cause unpredictable problems, especially as values become more complex. Always wrap attribute values in double quotation marks: lang="en", never lang=en.
Misconception 7
"Any file extension works as long as the content inside is valid HTML."
A browser decides how to interpret a file largely based on its extension. A file saved as index.txt or simply index will not be interpreted as HTML, no matter how correctly it is written inside. HTML files must be saved with the .html extension.
PracticeCode Reading

Read each HTML code block carefully. Answer the questions that follow without running the code first. Then open the code in a browser to check your predictions.

Exercise 5.1
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Welcome</title> </head> <body> <h1>Good Morning</h1> <p>Today is a fine day to learn HTML.</p> </body> </html>
  1. What text will appear in the browser tab?
  2. What element creates the large visible heading?
  3. Is the viewport meta tag present? What might be different on a mobile device because of this?
  4. Name one piece of information in head and one piece of content in body.
Exercise 5.2
<!DOCTYPE html> <html lang="fr"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Bienvenue — Mon Site</title> </head> <body> <h1>Bienvenue</h1> <p>C'est ma première page en HTML.</p> </body> </html>
  1. What language is this document declared to be written in?
  2. What does the lang attribute on the html element communicate to a screen reader?
  3. What will appear in the browser tab?
  4. What is the visible heading on the page?
Exercise 5.3
Find everything that is incorrect in this document
<html> <head> <title>My Blog</title> <p>Welcome to my blog!</p> </head> <body> <h1>Latest Posts <p>Here are my most recent writings.</p> </body>
  1. What is missing from the very beginning of the file?
  2. What important attribute is missing from the <html> tag?
  3. What element does not belong inside <head>?
  4. Which element is missing a closing tag?
  5. What is missing at the end of the document?
PracticePredict the Result

Read the code and predict what you will see in the browser window and in the browser tab before you open the file.

Exercise 5.4
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>Science Fair Project</title> </head> <body> <h1>My Experiment</h1> <p>I am testing how sunlight affects plant growth.</p> <p>I measured five plants over four weeks.</p> </body> </html>
  1. What text appears in the browser tab?
  2. How many lines of visible text appear in the browser window?
  3. Which line of visible text will be displayed differently from the others, and why?
PracticeDebugging and Error Analysis
Exercise 5.5
A student's page is not displaying correctly — find every error
<!DOCTYPE html> <html> <head> <title>My Portfolio<title> <meta charset=UTF-8> </head> <body> <h1>Welcome to My Portfolio</h1> <p>I am a student learning web development. <p>Here you will find my projects.</p> </body>

Find and describe every error, then write the corrected version.

Exercise 5.6
Which DOCTYPE declarations are correct?
<!-- A --> <!DOCTYPE html> <!-- B --> <!DOCTYPE HTML> <!-- C --> <!doctype html> <!-- D --> <DOCTYPE html> <!-- E --> <!-- This is my document --> <!DOCTYPE html>

Explain, for each one, why it is correct or incorrect.

PracticeShort Build Tasks
  1. Task 5.1. Write a complete valid HTML document for a page called "Reading List" for a fictional book club called "The Open Page Book Club." Include: a correct DOCTYPE declaration; a lang attribute set to English; a charset meta tag; a viewport meta tag; a browser tab title that reads "Reading List — The Open Page Book Club"; a visible heading that reads "Our Current Reading List"; and two paragraphs describing the club's reading selections. Make sure your code is properly indented.
  2. Task 5.2. Fix every error in the broken document below and rewrite the complete corrected version, documenting each error you found.
    <!DOCTYPE html> <html> <head> <title>Astronomy Club <head> <body> <h1>Welcome to Astronomy Club!</h1> <p>We meet on the first Friday of every month. <p>Bring a notebook and comfortable shoes for our outdoor sessions.<p> <body> <html>
  3. Task 5.3. A friend tells you: "I just write all my HTML page content directly in the <head> section because it is the most important part." Write a clear, friendly explanation of what is wrong with this approach, what the head section is actually for, and where visible page content belongs.
Running ProjectStudent Learning Site — Step 1

This is the first step in the course's running project. You will add to this project in every subsequent chapter.

Project Task
Create the project folder and the first HTML file
  • Step 1Create a project folder on your computer named student-learning-site containing a single file, index.html.
  • Step 2Open index.html and write a complete valid HTML document with: a correct DOCTYPE declaration; lang="en" on the html element; a charset meta tag using UTF-8; a viewport meta tag; a title element reading "Home — Student Learning Site"; a visible h1 heading reading "Welcome to the Student Learning Site"; and two paragraphs describing what the site is about.
  • Step 3Review your work against the checklist below before opening it in a browser.
  • Step 4Open your file in a browser and confirm the tab text, the heading, and both paragraphs all appear as expected.
student-learning-site/ index.html
Project Review Checklist
Confirm before opening index.html in the browser
  • The DOCTYPE declaration is on line 1 with nothing before it
  • The html element has lang="en"
  • The head section contains meta charset, meta viewport, and title
  • The body section contains the heading and paragraphs
  • All opening tags have matching closing tags
  • Indentation is consistent throughout
  • The file is saved with the .html extension
Save Your Work

Save your project folder. You will return to it in Chapter 6, where you will add headings, paragraphs, and semantic structure to the page content you just created.

PracticeAccessibility Check
Exercise 5.7
Review this document for accessibility issues
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Page</title> </head> <body> <h1>Our Club</h1> <p>We meet weekly to discuss topics we enjoy.</p> </body> </html>

For each issue you find, explain why it matters and how to fix it. Consider: Is the language of the document declared? Is the page title descriptive enough for a user who cannot see the page?

Mixed ReviewConnecting to Earlier Chapters

These questions draw on earlier chapters as well as Chapter 5. Answering them helps you connect new knowledge to what you already know.

  1. Exercise 5.8 (Chapters 1–5). A student builds a web page and opens it in the browser, but the page appears completely unstyled — no colors, no fonts, nothing but plain black text on a white background. (a) Is this a problem? Why or why not? (b) Which language would the student need to add to control colors, fonts, and spacing? (c) What does the browser do when there is no CSS on a page?
  2. Exercise 5.9 (Chapter 3). A student creates a project folder called my-site/ with a file called Homepage.HTML inside. They try to open the file in the browser but nothing useful appears. (a) What is likely wrong with the filename? (b) What are two problems with the filename that could cause issues on some systems?
  3. Exercise 5.10 (Chapter 2). Explain in your own words the difference between a file saved on your computer and opened directly in the browser versus a file that is published on a web server and accessed through a URL. What changes between those two situations?
Chapter 5 Checklist
Use this to confirm your understanding before moving to Chapter 6
Concepts
  • I can explain what HTML is and what it does not do.
  • I can identify the opening tag, content, and closing tag of an element.
  • I can name several void elements and explain why they need no closing tag.
  • I can write attributes correctly, including boolean attributes.
  • I can explain nesting and the rule that elements must not overlap.
  • I can apply consistent indentation to reflect document structure.
  • I can reproduce the basic HTML document skeleton from memory.
  • I can explain the purpose of the DOCTYPE declaration and standards mode.
  • I can distinguish the roles of html, head, and body.
  • I can explain the purpose of the title element and how it differs from h1.
Applications
  • I can write a complete, valid HTML starter page from scratch.
  • I can save an HTML file with the correct name and extension.
  • I can identify missing closing tags, overlapping elements, and missing attributes in broken code.
Study Habits
  • I trace example code line by line rather than skimming past it.
  • I check my own code against a structural checklist before opening it in a browser.
  • I treat browser errors and unexpected results as information to investigate, not as failure.
Preview — Chapter 6
Text, Headings, Paragraphs, and Semantic Elements

Chapter 5 gave you the skeleton of an HTML document — the structure that holds everything together. But a skeleton with no content is just an empty shell. Chapter 6 fills that skeleton with text. You will learn how to mark up headings at different levels, write paragraphs, add emphasis, and use semantic elements like main, section, article, header, and footer. You will build a complete structured article page and begin to understand why semantic HTML matters not just for appearance, but for accessibility and search engines. By the end of Chapter 6, you will be able to build an HTML page with meaningful, well-structured written content — the kind of page a screen reader can navigate clearly, a search engine can understand, and a human reader can follow logically.

MGU Library Connection
  • Web Development: HTML, CSS, and JavaScript — Appendix B: HTML Reference
  • Web Development: HTML, CSS, and JavaScript — Appendix M: Glossary
  • Companion resource: HTML Document Skeleton Guide
  • Companion resource: HTML Element Reference
  • Companion resource: Web Debugging Checklist
  • Next chapter: Chapter 6 — Text, Headings, Paragraphs, and Semantic Elements