Explain it simply
Explain it simply
A football player who has practised passing, trapping and shooting one at a time still needs a practice match, because only in a match do you learn which skill to use when. This lesson is HTML's practice match.
There are no new tags. You combine headings, paragraphs, lists, links and images on one page, and along the way you make the real decisions yourself: is this line a paragraph or a list item, and does this word deserve strong or em?
Problem → Why → Solution
The problem: it looks right but has no structure
When learners who know each tag on its own write their first full page, the result often looks like the code below. The title is made big with b and br tags, the list is typed by hand with "- ", and a nested ul sits outside any li.
The browser can display it, but a screen reader has no headings to jump between and cannot say how many items a list has. Search engines cannot tell what the page is mainly about. The image has no alt, so if it fails to load nothing at all is left in its place.
<body>
<b>Tea Leaf Salad</b><br><br>
- tea leaves<br>
- crunchy mix<br>
<ul>
<li>Steps</li>
<ul><li>Slice the tomato</li></ul>
</ul>
<a href="https://en.wikipedia.org/wiki/Lahpet">click</a>
<img src="salad.jpg">
</body>Why is this a problem?
HTML's job is to describe what content means; CSS handles how it looks. b and br never say "this is a heading" or "this is a list". Choose the right elements and screen readers, search engines, reader mode and the CSS you write later all understand the page.
Core concept: outline first, markup second
A good page is not typed straight into an editor. You sketch the content on paper, decide what each piece is, and only then choose tags. This exercise comes down to four decisions.
1. Write the outline
The title of the whole page is the h1 and each part is an h2. In the recipe, "Lahpet Thoke" is the h1 while "Ingredients" and "Steps" are h2. Read only the headings and you should get the page's table of contents.
2. Paragraph or list?
Connected sentences form a paragraph; separate items form a list. Use ol when order matters, as with cooking steps, and ul when it does not, as with ingredients. To split one item further, put the nested list inside that item's li.
3. Pick emphasis by meaning
strong says "this matters", while em marks the word you would stress when reading aloud. If you only want a bold or italic look, that is a job for CSS.
4. Finish links and images
Link text must say where it leads. target="_blank" opens a new tab, and rel="noopener" stops the opened page from controlling yours through window.opener. Give images alt, width and height so the browser reserves space before the file loads and the text does not jump.
| Content | Element |
|---|---|
| Steps that must happen in order | ol + li |
| Items whose order does not matter | ul + li |
| An important warning or key fact | strong |
| A word you stress when speaking | em |
Browsers collapse whitespace
If you split one paragraph across two lines in your code, the browser collapses the line break and extra spaces into a single space and shows one continuous sentence. So you can wrap code for readability, and when you truly need a new line, you use a new p or a br.
- h1 is the book title
- h2 headings are the chapters
- p and lists are the chapter text
- Links and images are refs and plates
Even with CSS switched off, reading the page top to bottom must make sense. That is the quickest test of whether the structure is right.
General pattern
<h1>Page title</h1>
<p>Intro with <strong>key fact</strong> and <em>stressed word</em>.</p>
<h2>Section</h2>
<ul>
<li>Item <ul><li>Sub-item</li></ul></li>
</ul>
<ol><li>First step</li><li>Second step</li></ol>
<a href="https://site.example/page" target="_blank" rel="noopener">Where it goes</a>
<img src="file.jpg" alt="What the image shows" width="W" height="H">Headings form the outline, paragraphs and lists hold the content, and links and images point at outside resources. Notice that the nested list lives inside the li.
Worked answer: a tea leaf salad recipe page
This page answers the exercise's four tasks using recipe content. Task 1 is the document shell, Task 2 the h1 and two paragraphs with strong and em, Task 3 a nested ul plus an ol, and Task 4 a new-tab link and an image. In the challenge you rewrite these patterns with new content, so focus on why each tag was chosen.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Lahpet Thoke (Tea Leaf Salad) Recipe</title>
</head>
<body>
<h1>Lahpet Thoke: Tea Leaf Salad</h1>
<p>This salad mixes <strong>fermented tea leaves</strong> with crunchy beans,
peanuts and fresh tomato. It is a favourite snack to offer guests.</p>
<p>The leaves taste <em>sour and slightly bitter</em>, so add them
a little at a time.</p>
<h2>Ingredients</h2>
<ul>
<li>2 tablespoons fermented tea leaves</li>
<li>Crunchy mix
<ul>
<li>fried broad beans</li>
<li>roasted peanuts</li>
<li>toasted sesame seeds</li>
</ul>
</li>
<li>1 tomato and a wedge of cabbage</li>
</ul>
<h2>Steps</h2>
<ol>
<li>Slice the tomato and cabbage thinly.</li>
<li>Mix in the tea leaves and a squeeze of lime.</li>
<li>Add the crunchy mix just before serving.</li>
</ol>
<p>Read the history of
<a href="https://en.wikipedia.org/wiki/Lahpet" target="_blank" rel="noopener">lahpet
on Wikipedia</a>.</p>
<img src="lahpet-thoke.jpg" width="600" height="400"
alt="Tea leaf salad on a plate, topped with peanuts and fried beans">
</body>
</html>Code breakdown
- Key fact
<strong>fermented tea leaves</strong>It is the salad's essential ingredient, so strong marks it as important. Its default style is bold.
- Stress emphasis
<em>sour and slightly bitter</em>This is the part you would stress aloud, so it gets em. Some screen readers change their voice for em, though not all do. The default style is italic.
- Nested list inside li
<li>Crunchy mixThe sub-list's ul sits inside this li, before its closing </li>. A ul may only have li elements as direct children, so a ul placed straight after another li inside the outer ul is invalid.
- Ordered steps
<ol>You slice before you mix and add the crunchy mix last, so the order carries meaning. That is why it is an ol, which the browser numbers 1, 2, 3.
- Safe new-tab link
<a href="https://en.wikipedia.org/wiki/Lahpet" target="_blank" rel="noopener">lahpetThe link text "lahpet on Wikipedia" says exactly where it goes. Modern browsers already treat target="_blank" as noopener by default, but writing rel="noopener" states the intent and still protects older browsers.
- Image with reserved space
<img src="lahpet-thoke.jpg" width="600" height="400"width and height let the browser reserve space before the download finishes. If the image fails, the alt text is shown instead, and screen readers read that same text.
Under the large heading "Lahpet Thoke: Tea Leaf Salad" come two paragraphs, with "fermented tea leaves" in bold and "sour and slightly bitter" in italics. Ingredients shows a bulleted list with an indented sub-list using hollow-circle bullets, Steps shows a list numbered 1. 2. 3., then a link that opens in a new tab and a 600x400 image (or a broken-image icon with the alt text if the file is missing).Check yourself before saying done
This lesson includes an answer, but your page does not need to match it word for word. What matters is whether the structure is right, and you can verify that yourself with nothing but a browser in four steps.
1. Run it through the validator
Upload the file at validator.w3.org/nu. A nested list outside its li, an unclosed tag or an image without alt shows up immediately.
2. Read only the headings
Read the h1 and h2 headings in order and confirm they work as a table of contents for the page.
3. Reach the link with Tab
Press Tab until the link has focus, then press Enter. A new tab should open while your original page stays put.
4. Break the image on purpose
Change one letter of the src file name and reload. The alt text should appear where the image was, with a small broken-image icon. If the alt alone tells you what the picture showed, it is a good alt.
In real projects
In real projects
Blog posts, documentation pages, recipe sites and news articles are all built from the handful of elements in this exercise. In a content management system, when a writer picks "Heading 2" or "Bulleted list" in the editor, an h2 or a ul is generated behind the scenes. Developers who understand these elements write CSS that fits them.
Recipe sites care about structure in particular: ingredients and steps written as real lists work far better in browser reader modes, voice assistants and search engines. Team reviews often include three quick checks: read the page with CSS switched off, Tab through every link, and temporarily misspell an image file name to confirm the alt text appears.
Common mistakes
Common mistakes
Putting a nested list outside the li
<ul><li>Fruits</li><ul>...</ul></ul> still renders, but the validator reports an error and a screen reader cannot tell which item the sub-list belongs to. Close the </li> only after the sub-list.
Choosing headings for their look
Writing "Ingredients" as an h4 because you want smaller text, or adding a second h1 just to make a line big, breaks the outline. Choose the level by importance and adjust the size in CSS.
"click here" links and images without alt
Screen reader users often pull up a list of every link on the page; five links reading "click here" are indistinguishable there. An image without alt may be announced by its file name, such as "IMG_2034.jpg".
Mini challenge
A one-day guide page for a town
Write a "one day in..." guide page for a town you like (Bagan, for example) that meets all four original tasks. Do not copy the recipe example; decide the structure yourself for the new content.
- Task 1: a complete document with doctype, lang, charset, viewport and title
- Task 2: one h1 and two paragraphs that use strong and em for meaning
- Task 3: a ul packing list with one nested list, and an ol for the day's schedule
- Task 4: a link with target="_blank" rel="noopener" and an image with alt, width and height
<!DOCTYPE html>
<html lang="en">
<head>
<!-- TODO (Task 1): charset, viewport, a title naming the town -->
</head>
<body>
<!-- TODO (Task 2): h1, then two paragraphs using strong and em -->
<!-- TODO (Task 3): h2 "What to pack" + ul with one nested list -->
<!-- TODO (Task 3): h2 "Plan for the day" + ol in time order -->
<!-- TODO (Task 4): link that opens in a new tab, with rel="noopener" -->
<!-- TODO (Task 4): img with alt, width and height -->
</body>
</html>Expected: The browser shows one h1, two h2 headings, two paragraphs with bold and italic words, a bulleted list with an indented sub-list, a numbered list, a link that opens a new tab and the image (or its alt text). It reads clearly with no CSS at all.
Show hint
Before writing code, jot down just the three or four headings on paper. The schedule runs from morning to evening, so it is an ol; the packing items have no order, so they form a ul.
Show solution
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>One Day in Bagan: A Simple Plan</title>
</head>
<body>
<h1>One Day in Bagan</h1>
<p>Bagan has <strong>thousands of ancient temples</strong> spread across a wide plain,
so a plan saves you hours of riding in the heat.</p>
<p>Start <em>before</em> sunrise: the light is softest and the roads are quiet.</p>
<h2>What to pack</h2>
<ul>
<li>Water and a hat</li>
<li>Temple clothes
<ul>
<li>a top that covers your shoulders</li>
<li>sandals that slip off easily</li>
</ul>
</li>
<li>A charged phone for maps</li>
</ul>
<h2>Plan for the day</h2>
<ol>
<li>Watch the sunrise from a viewing mound.</li>
<li>Visit Ananda Temple in the morning.</li>
<li>Rest through the midday heat.</li>
<li>Watch the sunset over the Irrawaddy River.</li>
</ol>
<p>Check opening times on the
<a href="https://en.wikipedia.org/wiki/Bagan" target="_blank" rel="noopener">Bagan
page on Wikipedia</a>.</p>
<img src="bagan-sunrise.jpg" width="800" height="450"
alt="Hot-air balloons drifting over Bagan's temples at sunrise">
</body>
</html>Quick quiz 1 / 3
Quick quiz 2 / 3
Quick quiz 3 / 3
What to remember
- Sketch the heading outline before writing markup
- Use ol when order matters, ul when it does not, and nest lists inside an li
- strong means importance, em means stress, and pure looks belong in CSS
- Make link text name the destination and give every image alt, width and height
HTML Living Standard — WHATWG