HTML chapters

Chapter 8 of 17

Lists and repeated content

Try this in our HTML Compiler →

The idea

HTML has no for or while loop. An unordered list groups items without ranking; an ordered list represents a sequence. Each item uses li. To generate hundreds of items from data, a script or server must produce the markup; the browser does not repeat a template merely because it exists.

Worked example

<ol>
  <li>Read the explanation.</li>
  <li>Write the example.</li>
  <li>Check the result.</li>
</ol>

What to check

The ordered list communicates step order. Changing it to ul removes that sequence meaning even if the items remain the same.

Practice task

Create an unordered equipment list and a separate ordered study plan. Explain why each uses its chosen list type.

Check your understanding

Explain the result in your own words before changing the example. Change one thing at a time, compare the result with your prediction, and keep the version that demonstrates the concept clearly.

Try it yourself

Output
Ctrl/Cmd+Enter runs · Ctrl/Cmd+S downloads the project · Local auto-save is always on