Module 1

HTML Essentials

The Cut Method β€’ DOM Trees β€’ Tags & Syntax

🌳 Think in Structure, Not in Code

Before writing a single line of HTML, great developers do something surprising: they look at the design and think about its structure. Not colors, not fonts β€” structure.

Every web page is a tree. The browser reads your HTML and builds this tree β€” called the DOM (Document Object Model). Your job is to describe that tree correctly. That's what HTML is: a language for describing trees.

A Web Page Is a Tree

page header content logo nav title text Root Container Final element

🎯 By the end of this module, you will:

  • Distinguish containers from final elements
  • Apply the Cut Method to decompose any design into a DOM tree
  • Understand the base structure of every HTML document
  • Write valid HTML with proper tags, attributes, and nesting
  • Use the 20 most essential HTML tags confidently

πŸ“¦ Two Categories: Containers & Final Elements

Every visible element on a web page falls into one of two categories. This is the most important idea in this module β€” once you see it, you can't unsee it.

πŸ“¦ Containers

Hold other elements inside them. They are branches of the tree β€” they exist to organize and group.

header nav main section div footer

πŸƒ Final Elements

Display actual content β€” text, images, links, buttons. They are leaves of the tree β€” nothing lives inside them.

h1 p img a button input
πŸ’‘
The key question: When you look at a region of a design, ask: "Does this contain other distinct elements?" If yes β†’ it's a container. If no β†’ it's a final element.
⚠️
HTML is tolerant β€” but we won't be. HTML won't throw an error if you put elements inside a <p>, or if a <div> contains only text with no children. The browser will try to render it anyway. But just because it works doesn't mean it's correct. As developers who do things the right way, we always respect the roles: containers contain, final elements display. Clean structure = fewer bugs, better accessibility, easier maintenance.

Spot the Categories

Home About Contact
Welcome!
Lorem ipsum dolor sit amet

πŸ“„ The Document Base

Every HTML document has the same skeleton. Think of it as the trunk and first two branches of your tree β€” they're always there, before any content:

The HTML Skeleton Tree

<html> <head> <body> metadata, title, links all visible content
<html>

The root. Everything lives inside it. Always the top of the tree.

<head>

Invisible metadata: page title, character set, external stylesheets, SEO tags. The browser reads it, but the user never sees it.

<body>

Everything the user sees goes here. This is where you'll build your tree β€” all visible content lives inside <body>.

πŸ“
The rule: Every HTML page starts with this skeleton. In the next section, you'll discover the Cut Method β€” a visual algorithm to build the tree inside <body>.

βœ‚οΈ The Cut Method

The Cut Method is an approach I developed to teach my students how to think in structure before writing a single line of code. It's a recursive algorithm for turning any visual design into a DOM tree β€” and it works for any page, simple or complex.

The Algorithm

1
Take a region

Start with the whole page (or any sub-region).

2
Try horizontal cuts ─

Can you draw horizontal lines that separate the region into distinct groups?

βœ“
Multiple groups?
a Name each group.
b For each group, ask: is it a final element or a container?
Final β†’ STOP
Container β†’ back to Step 1
β†’
One group?
Go to step 3 ↓
3
Try vertical cuts β”‚

Can you draw vertical lines that separate the region into distinct groups?

βœ“
Multiple groups?
a Name each group.
b For each group, ask: is it a final element or a container?
Final β†’ STOP
Container β†’ back to Step 1
β– 
Still one group?
It's a final element. STOP.
⚠️
Direction annotations matter! Horizontal cuts (─) produce a column layout (elements stacked vertically). Vertical cuts (β”‚) produce a row layout (elements side by side). This maps directly to Flexbox in Module 7!

🎴 Worked Example 1: A Profile Card

Let's apply the Cut Method to a simple component β€” a profile card. Watch the cuts appear and the tree build itself.

Design

πŸ‘€
Jane Doe
Web Developer
Follow Message

DOM Tree

Step 0 / 5

Click "Next" to start the Cut Method on this profile card.

🌐 Worked Example 2: A Full Page

Now let's scale up. Here's a typical webpage with a header, hero section, three feature columns, and a footer. The Cut Method handles it all.

Design

Home About Contact
Welcome to Our Site
Building the future of the web
⚑
Fast
πŸ”’
Secure
πŸ“±
Responsive

DOM Tree

Step 0 / 10

Click "Next" to start the Cut Method on this full page.

✏️ Practice: Build the Tree

Your turn! Look at each design below and build its DOM tree using the Cut Method. Drag elements into the correct position in the tree.

Exercise 1: Blog Post

πŸ“· Photo
My First Blog Post
Jan 15, 2026 Β· 5 min read
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt...
  • ↳ Drop root element here
πŸ“¦ article
πŸƒ img
πŸƒ h2
πŸƒ p (meta)
πŸƒ p (text)

Exercise 2: Navigation Bar

Sign Up
  • ↳ Drop root element here
πŸ“¦ nav
πŸƒ img (logo)
πŸ“¦ ul
πŸƒ li Γ— 4
πŸƒ button

Exercise 3: E-Commerce Product Card

πŸ“· Product
Wireless Headphones
$79.99
β˜…β˜…β˜…β˜…β˜†
Add to Cart β™‘
  • ↳ Drop root element here
πŸ“¦ article
πŸƒ img
πŸ“¦ div (info)
πŸƒ h3
πŸƒ span (price)
πŸƒ span (rating)
πŸ“¦ div (actions)
πŸƒ button (cart)
πŸƒ button (β™‘)

πŸ—οΈ HTML Syntax: Writing the Tree

You now know what to build (the tree). Let's learn how to write it. HTML uses tags β€” small text labels wrapped in angle brackets β€” to describe every node of the tree you designed with the Cut Method.

πŸ”¬ Anatomy of a Tag

Every HTML element is written with tags. A tag is a keyword wrapped in angle brackets < >. Most elements use two tags β€” one to open, one to close β€” with the content in between.

<p class="intro">Hello, world!</p>
Opening tag
Attribute
Content
Closing tag

The opening tag is everything from <p to >, including any attributes. The closing tag is always </tagname>. Together they form the element.

🏷️
Tag name

The keyword tells the browser what this element is: p = paragraph, h1 = heading, div = generic container.

πŸ”§
Attributes

Extra info inside the opening tag. Usually name="value" format: class="intro", href="...". Some are boolean (no value needed): disabled, required, hidden.

πŸ“
Content

What goes between the opening and closing tags: text, or other nested elements (children in the tree).

πŸ”’
Closing tag

Same tag name with a / slash: </p>. Tells the browser "this element ends here." Forgetting it is the #1 beginner mistake.

πŸƒ Void Elements (No Closing Tag)

Some elements never have children or text content β€” they are void (empty) by nature. In HTML5, they simply have no closing tag. In your tree, these are always final elements (leaves πŸƒ).

<img src="photo.jpg" alt="A sunset"> Displays an image. src = where, alt = description.
<br> Line break. Forces text to the next line.
<input type="text" placeholder="Name"> A form field. The user types inside it.
<hr> Horizontal rule. A visual separator line.
β›”
Our Rule: Never use HTML for styling! Tags like <br> and <hr> exist in HTML, but they are presentational β€” their only purpose is to change how things look. HTML = structure, CSS = presentation.
⚠️
How to know if an element is void? Ask yourself: "Can this element contain text or other elements?" If no β†’ it's a void element (no closing tag). An <img> can't contain a paragraph. An <input> can't contain a heading. They are always leaves in the tree.

🌳 Nesting: Tree β†’ Code

This is the key concept: every container in your tree becomes a pair of opening + closing tags. Its children go inside. Every level of nesting = one level of indentation.

🌳 Tree (Cut Method)
πŸ“¦ nav
πŸƒ img
πŸ“¦ ul
πŸ“¦ li
πŸƒ a
πŸ“¦ li
πŸƒ a
πŸ“¦ li
πŸƒ a
β†’
πŸ“ HTML Code
<nav>
<img src="logo.png" alt="Logo">
<ul>
<li><a href="/">Home</a></li>
<li><a href="/about">About</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
1 πŸ“¦ Container β†’ opening tag, then children inside, then closing tag
2 πŸƒ Final (with content) β†’ opening tag + text + closing tag: <p>Hello</p>
3 πŸƒ Void element β†’ opening tag only, no closing tag: <img>, <input>
4 ↳ Convention: each child is indented (usually 2 spaces) deeper than its parent for readability

πŸ“„ The Full Page Skeleton

Every HTML page follows the same skeleton. Here's the tree, then the code that writes it:

🌳 DOM Tree
βš™οΈ !DOCTYPE
πŸ“¦ html
πŸ“¦ head
πŸƒ meta charset
πŸƒ title
πŸ“¦ body
πŸ’¬ your tree here…
β†’
πŸ“ HTML Code
<!DOCTYPE html>
<html lang="en">

  <head>
    <meta charset="utf-8">
    <title>My Page</title>
  </head>

  <body>
    <!-- your tree here -->
  </body>

</html>
<!DOCTYPE html>

Not a tag β€” a declaration. Tells the browser to render in standards mode. Always first line.

<html lang="en">

The root container. The lang attribute tells the browser the page language.

<head>

Invisible metadata: page title, links to CSS files. Users never see this section.

<meta charset="utf-8">

Tells the browser how to read characters (accents, emoji…). Always include it.

<body>

Everything visible on the page. Your entire tree from the Cut Method goes here.

⌨️
Try It Yourself

Open this example in our playground β€” edit the code and see the result update live.

Open in Playground β†’

🏷️ The Essential Tags

Here's your reference toolkit β€” the 20 tags you'll use in 90% of your HTML. Hover over any tag to see a live example.

πŸ›οΈ Page Structure

These tags define the big zones of your page. They are all containers πŸ“¦.

<header> Top section of a page or block
<nav> Navigation links
<main> Primary content (one per page)
<section> Thematic grouping of content
<article> Self-contained content (post, card…)
<aside> Side content (sidebar, note…)
<footer> Bottom section of a page or block
<div> Generic container (no meaning)

πŸ“ Text & Content

The building blocks for text, headings, lists, media, and links.

<h1>–<h6> Headings (h1 = most important)
<p> Paragraph of text
<a> Hyperlink (anchor)
<strong> Strong importance β€” screen readers stress this text
<em> Emphasis β€” screen readers change tone for this text
<span> Inline text wrapper (no meaning)
<ul> / <ol> Unordered / ordered list
<li> List item (inside ul or ol)
<figure> Media wrapper with caption
<figcaption> Caption for a figure
<blockquote> Block quotation

πŸ–ΌοΈ Media & Embeds

Images, videos, audio β€” the visual and interactive parts of a page. Most are void elements πŸƒ (no closing tag).

<img> Image (void element)
<video> Video player
<audio> Audio player
<iframe> Embedded page / widget
<hr> Horizontal rule / separator (void)
<br> Line break (void element)

πŸ“‹ Forms & Inputs

Everything for user input: text fields, buttons, checkboxes, dropdowns.

<form> Form container (wraps inputs)
<input> Text field, checkbox… (void)
<button> Clickable button
<label> Label for a form field
<select> Dropdown menu
<textarea> Multi-line text input

πŸ“Š Tables

For tabular data β€” schedules, statistics, comparisons. Not for page layout!

<table> Table container
<tr> Table row
<th> / <td> Header cell / data cell

πŸ“‹ Module Summary

🌳
DOM Tree

Every web page is a tree. The browser builds it from your HTML. Your job: describe the tree correctly.

πŸ“¦
Two Categories

Containers hold other elements (branches). Final elements display content (leaves).

βœ‚οΈ
The Cut Method

Horizontal cuts β†’ column layout. Vertical cuts β†’ row layout. Recurse until you reach final elements.

πŸ“„
Document Base

<html> β†’ <head> + <body>. All visible content goes in <body>.

πŸ—οΈ
HTML Syntax

Opening tag + content + closing tag. Attributes add info. Void elements have no closing tag.

🏷️
Essential Tags

33 tags in 5 groups β€” structure, text, media, forms, tables β€” cover 90% of everything you'll build.

Next Module β†’

Module 2: Semantic HTML & Structure

Now that you can build trees and write HTML, it's time to choose the right tags. Semantic HTML for accessibility, SEO, and clean architecture.

β†’