Skip to main content
Module 1 · Lesson 2 of 42/60 in the course~16 min
Module lessons (2/4)

Text, Headings & Document Hierarchy

Headings Are a Table of Contents, Not Font Sizes

Beginners frequently pick <h4> because <h2> looked "too big" on screen. That breaks accessibility: screen reader users press shortcut keys (H or 1–6) to skim a page's outline, trusting that an <h3> sits logically underneath an <h2>.

Use one <h1> for the main page topic, use <h2> for top-level sections, and nest <h3> inside those sections. If a heading looks too large, shrink it later with CSS—never pick a wrong level!

ElementSemantic MeaningWhen to Avoid
<h1>Primary page title (one per page)Repeating for every hero banner card
<h2>–<h6>Nested sub-sections in sequential orderJumping directly from <h1> to <h3>
<p>Standalone prose paragraphSpacing empty lines with <p></p>
<strong>Urgent or high-importance phraseMere visual bold weight for logos
<em>Spoken stress that shifts meaningDecorative italics on metadata tags
<code>Computer code, tag name, or CLI commandLong multi-line blocks without <pre>
<blockquote>Multi-sentence external quotationIndenting ordinary text visually

Example 1 — Clean Logical Outline

Notice how every level steps down cleanly by one:

HTML
<main>
  <h1>Complete Coffee Roasting Guide</h1>
  <p>From green beans to balanced morning espresso.</p>

  <h2>1. Choosing Green Beans</h2>
  <h3>Altitude and Density</h3>
  <p>High-grown Arabica beans carry brighter acidity.</p>

  <h2>2. Controlling Heat</h2>
  <p>Wait until the <strong>first crack</strong> before cooling.</p>
</main>

Example 2 — Code Snippets & Quotes

Wrap multi-line code inside <pre><code>...</code></pre> to preserve indentation, and pair <blockquote> with <footer> or <cite> for attribution:

HTML
<p>Inspect CSS specificity in prose with <code>:where()</code>.</p>

<blockquote>
  <p>Good design is as little design as possible.</p>
  <footer>— <cite>Dieter Rams</cite></footer>
</blockquote>
Practice Stage

Step 1 — Fix a skipped heading hierarchy

Exercise#html-css.m1.l2.e1
Attempts: 0Loading…

Fix the skipped heading levels inside <main> so the page starts with one <h1>, followed by an <h2> section and a nested <h3> subsection.

Loading editor…
Show hint

Change <h4> to <h2> and <h5> to <h3> so levels go 1 -> 2 -> 3 without skipping.

Solution available after 3 attempts

Practice Stage

Step 2 — Add semantic emphasis and inline code

Exercise#html-css.m1.l2.e2
Attempts: 0Loading…

Inside the <p>, wrap 'git status' in <code>, mark 'never force push' with <strong>, and emphasize 'shared' using <em>.

Loading editor…
Show hint

Wrap the command in <code>git status</code>, urgent rule in <strong>never force push</strong>, and word "shared" in <em>shared</em>.

Solution available after 3 attempts

Practice Stage

Step 3 — Quote with attribution cleanly

Exercise#html-css.m1.l2.e3
Attempts: 0Loading…

Convert the raw quote div into a semantic <blockquote> holding the quote inside a <p> and citing 'Tim Berners-Lee' inside <cite>.

Loading editor…
Show hint

Replace <div class="quote"> with <blockquote>, wrap the sentence in <p>, and wrap Tim Berners-Lee in <cite>.

Solution available after 3 attempts

HTML & CSS Quiz#html-css.m1.l2.e4
Ready

Your designer wants a subtitle below <h1> to look small (14px). What is the cleanest semantic choice?

Answer options
HTML & CSS Quiz#html-css.m1.l2.e5
Ready

How does <strong> differ from CSS font-weight: bold?

Answer options