3 / 10 · Intro
Headings and paragraphs
HTML has six heading levels, h1 to h6, and screen reader users often jump from heading to heading to find their way around a page.
Jump to the 10 practice questionsYou will learn
- Build an outline with h1 to h6 without skipping levels
- Write paragraphs and line breaks where they belong
- Mark quotations with blockquote
Before this: Tags and elements
1Explain
An outline made of headings
Think of a recipe book. The book has a title, each recipe has a name, and each recipe has smaller parts such as Ingredients and Method. HTML expresses the same outline with six heading elements, <h1> through <h6>. <h1> is the top level, usually the title of the page.
<h1>Weekend Baking</h1>
<p>Three simple breads you can make at home.</p>
<h2>Soda bread</h2>
<h3>Ingredients</h3>
<p>Flour, baking soda, salt and buttermilk.</p>
<h3>Method</h3>
<p>Mix, shape into a round and bake for 40 minutes.</p>
<h2>Flatbread</h2>
<p>Ready in 20 minutes, no oven needed.</p>2Explore
Pick the level by structure
Two habits keep the outline clean. First, use one <h1> per page for its main title; MDN recommends this, and it is what most users expect. Second, do not skip levels on the way down: after an h2 comes an h3, not an h5. Going back up is fine, so an h3 can be followed by a new h2 when the next section starts.
The level changes the size, but its job is to place the heading in the outline: under an h1, the next level is h2.
Tap a choice: the code and the preview change together.
<h1>Recipes</h1>
<h2>Soda bread</h2>
<p>No yeast, no waiting.</p>Nothing is drawn: there is no visible content.
3Problem
How many h1?
How many h1 elements should a typical page have?
Hint
One main title per page.
Solution
Answer: 1
One h1 for the main title, as MDN recommends.
4Problem
After an h2
After an h2, which heading should start a subsection?
Hint
Do not skip a level.
Solution
Answer: h3
Go down one level at a time; skipping to h5 breaks the outline.
5Explain
Example: an outline from a table of contents
A small book has a title, two chapters, and two sections in the first chapter. Give each line a heading level.
- The book title is the top of the outline: h1.
- The chapters Starters and Shaping sit one level down: h2.
- Feeding and Storing are parts of Starters, one more level down: h3.
- Shaping starts a new chapter, so the outline goes back up to h2. Going back up is fine; jumping down two levels is not.
<h1>Bread at Home</h1>
<h2>Starters</h2>
<h3>Feeding</h3>
<h3>Storing</h3>
<h2>Shaping</h2>6Problem
Back up a level
<h1>Garden Club</h1>
<h2>Vegetables</h2>
<h3>Tomatoes</h3>
<h2>Flowers</h2>Is this outline correct?
Hint
Only a jump down past a level breaks an outline.
Solution
Answer: Yes: going back up from h3 to h2 is fine
Flowers is a new part at the same level as Vegetables, so it is an h2 again. Going back up is always fine; only a jump down, such as h2 to h4, skips a level.
7Explore
Paragraphs and line breaks
Running text goes in <p> elements, one per paragraph. Because HTML collapses white space, pressing Enter twice in your file does not create a new paragraph on screen; only a new <p> does. Browsers add a gap above and below each paragraph by default, which CSS can change. A paragraph cannot contain another paragraph or a heading, so if you forget a closing </p>, the browser closes it for you as soon as the next block element starts.
Extra spaces and line breaks in the file collapse into one space. A new paragraph needs a new p; a line break inside one needs br.
Tap a choice: the code and the preview change together.
<p>Line one
Line two</p>Nothing is drawn: there is no visible content.
8Problem
Enter twice inside p
You press Enter twice between two sentences inside one p. What appears?
Hint
White space in the file collapses.
Solution
Answer: A single space
White space, line breaks included, collapses into one space.
9Problem
The source of a long quotation
A blockquote copies a paragraph from another web page. Which attribute holds the address of that page?
Hint
It is not an attribute of a link or an image.
Solution
Answer: cite
cite on blockquote holds the address of the source. Browsers do not show it, so if readers should see where the words come from, name the source in the text as well. href belongs to links, src to images.
10Explain
Quotations
A longer quotation from another source goes in <blockquote>, which browsers indent. Put the quoted paragraphs inside it, and you can give the source address in its cite attribute. A short quotation inside a sentence uses <q>, and the browser adds quotation marks for you. The <cite> element marks the title of a work, such as a book or a film.
<blockquote cite="https://example.com/baking">
<p>Good bread needs time more than skill.</p>
</blockquote>
<p>From a baking guide</p>11Problem
A short quotation
A few quoted words sit inside a sentence. Which element marks them?
Hint
The long form is indented as its own block; the short form stays in the sentence.
Solution
Answer: q
q is for a short quotation inside a sentence, and the browser adds the quotation marks. blockquote is for a longer one; cite marks the title of a work.
12Problem
A change of topic
Hint
It is a void element drawn as a line.
Solution
Answer: hr
hr is the thematic break.
13Practice
Headings for the bike club
Turn Bike Club into an <h1>, and Routes and Joining into <h2> headings. Leave the other lines as paragraphs.
- h1 Bike Club
- two h2 headings
- paragraph after Routes
- three paragraphs left
<p>Bike Club</p>
<p>We ride every Saturday morning.</p>
<p>Routes</p>
<p>Most rides are 30 to 50 km on quiet roads.</p>
<p>Joining</p>
<p>Come to the park gate at 8 am with a helmet.</p>Hint
Change only the tag names of three lines: p becomes h1 or h2.
A solution
<h1>Bike Club</h1>
<p>We ride every Saturday morning.</p>
<h2>Routes</h2>
<p>Most rides are 30 to 50 km on quiet roads.</p>
<h2>Joining</h2>
<p>Come to the park gate at 8 am with a helmet.</p>14Practice
An address on three lines
Put the shop name, the street and the town on three separate lines with <br>.
- two line breaks
- address kept
<address>
Corner Bakery 12 Mill Street Springfield
</address>Hint
Two br elements make three lines.
A solution
<address>
Corner Bakery<br>
12 Mill Street<br>
Springfield
</address>15Explain
Common mistakes
<h1>Bike Club</h1>
<h4>Routes</h4>
<p>Quiet roads.</p><h1>Bike Club</h1>
<h2>Routes</h2>
<p>Quiet roads.</p>h4 was picked because it looked smaller. The outline then jumps from level 1 to level 4; use h2 and change the size with CSS.
16
Summary
- h1 to h6 build an outline: one h1, then go down one level at a time.
- Choose heading levels by structure; change size with CSS.
- One p per paragraph; br only where line breaks are content; hr for a change of topic.