HTML: lists, tables and parts of a page

Lesson 3 of 17 · HTML, CSS and JavaScript

Lists, class timetables and competition results are shown with lists and tables. This lesson also shows the semantic elements (header, nav, main, footer…) that divide a page into meaningful parts.

Before you start: required prior knowledge – text, links and images.
How to learn: do the tasks at the end on your own in your editor first; open the hint and the solution only after that. Every example has the code and a live result below it; type the code into your own file and change it.

Lists

<h3>Unordered list (ul)</h3>
<ul>
  <li>HTML</li>
  <li>CSS</li>
  <li>JavaScript
    <ul><li>DOM</li><li>events</li></ul>
  </li>
</ul>
<h3>Ordered list (ol)</h3>
<ol>
  <li>Write the HTML</li>
  <li>Add CSS</li>
  <li>Bring it to life with JavaScript</li>
</ol>

Result:

ul (unordered) is a bulleted list, ol (ordered) a numbered list, and each item is an li. A list can be inside an item of another list. An ordered list has the attributes start="5" (from which number) and type="a" (letters instead of numbers). The navigation menus of websites are most often unordered lists of links.

Tables

<table border="1" cellpadding="6">
  <caption>Results – municipal competition</caption>
  <thead>
    <tr><th>Name</th><th>Grade</th><th>Points</th></tr>
  </thead>
  <tbody>
    <tr><td>Anna</td><td>7</td><td>300</td></tr>
    <tr><td>Mark</td><td>7</td><td>245</td></tr>
    <tr><td colspan="2">Average</td><td>272.5</td></tr>
  </tbody>
</table>

Result:

ElementMeaning
tablethe whole table
captionthe title of the table
thead / tbodythe head / body of the table
tra row (table row)
tha header cell (bold, centred)
tdan ordinary cell (table data)
colspan / rowspana cell spans several columns / rows

The attributes border and cellpadding are here only so that the table is visible without CSS; in real projects the look of a table is set with CSS. Tables are for data, not for laying out parts of a page – for layout you use CSS (flexbox and grid).

Semantic parts of a page

In the past all parts of a page were made of div elements. Today there are elements that say what each part is:

┌──────────────── header ─────────────────┐
│  logo, site title                        │
├──────────────── nav ────────────────────┤
│  Home | Projects | Contact               │
├──────── main ─────────────┬── aside ────┤
│  section                   │  extra:     │
│    article                 │  links,     │
│    article                 │  ads        │
├──────────────── footer ─────────────────┤
│  © 2026, contact                         │
└─────────────────────────────────────────┘
<header>
  <h1>School code club</h1>
  <nav>
    <a href="#">Home</a> | <a href="#">Projects</a> | <a href="#">Contact</a>
  </nav>
</header>
<main>
  <article>
    <h2>Our first website</h2>
    <p>An article with its own heading and text.</p>
  </article>
</main>
<footer>
  <p>&copy; 2026 Computer club</p>
</footer>

Result:

They look like ordinary blocks, but they help screen readers (the user can "jump" to the main content), search engines and you yourself when you read the code. The div element is still used – for grouping that has no special meaning, most often because of CSS. Its counterpart for a piece of text within a line is span.

Block and inline elements

BlockInline
how it is placedstarts on a new line, takes the full widthstays in the line with the text, as wide as its content
examplesh1–h6, p, ul, ol, li, table, div, header, main, sectiona, strong, em, span, img, code

This difference matters for CSS: width and height are set on block elements, not on inline ones (more about this in the lesson The box model).

Practice tasks

Each task has an example, a hint and a solution. The solutions have been checked in the browser.

TASK 01Difficulty: medium

A class timetable

Make a timetable table for three days (Monday, Tuesday, Wednesday) and four lessons, with a table title and a header. Let one lesson (e.g. "Computer science – double lesson") span two rows with rowspan.

TASK 02Difficulty: medium

A page with semantic parts

Change the "About me" page from the first lesson so that it has a header with the title and navigation (an unordered list with three anchors), a main with three section elements and a footer.

Common mistakes and tips
  • Do not use a table to lay out a page – only for data.
  • Every li must be inside a ul or an ol.
  • Do not build a whole page out of divs when a suitable semantic element exists.

Check your knowledge

Open the quiz

Lists, tables and parts of a page

1. Which element makes a numbered list?




2. Which element is a table header cell?




3. Where is the main, unique content of a page?




4. What kind of element is span?