Book a free demo

Web Developer Path ยท lesson 3 of 18

Links, lists and tables

Link pages together, list things in order, and arrange data in rows and columns with a table.

What you will learn

  • links: <a href="โ€ฆ">, absolute and relative addresses, target, mailto:
  • bulleted lists <ul> and numbered lists <ol> made of <li> items
  • tables: <table>, <tr> rows, <th> heading cells and <td> data cells

Understand the idea

A link is made with the <a> tag, short for anchor. The href attribute says where it goes and the words between the tags are what people click: <a href="https://example.com">Visit</a>. A full address is an absolute link. A short one such as about.html is relative to the current page. href="#top" jumps to the element with id top on the same page, and mailto: opens an email. target="_blank" opens a new tab; pair it with rel="noopener" for safety. Write link text that makes sense alone, not just "click here".

Lists group related items. <ul> is an unordered list shown with bullets, <ol> is an ordered list shown with numbers, and every item is an <li>. A list can contain another list inside an item, which creates an indented sub-list.

Tables show data in rows and columns. <table> is the whole table, each <tr> is a row, <th> is a heading cell (bold and centred by default) and <td> is a normal data cell. Every row should have the same number of cells. <caption> gives the table a title, and colspan lets one cell stretch across several columns. Use tables only for data, never to arrange a page layout.

Example

A link, a list and a table
<a href="#top">Back to top</a>

<ol>
  <li>Mix the dough</li>
  <li>Let it rise</li>
  <li>Bake</li>
</ol>

<table>
  <caption>Pizza prices</caption>
  <tr><th>Size</th><th>Price</th></tr>
  <tr><td>Small</td><td>150</td></tr>
  <tr><td>Large</td><td>320</td></tr>
</table>

The table has one heading row and two data rows; every row has two cells. The ordered list numbers itself.

Your turn: code to type and practise

Build a timetable table with a heading row of three th cells (Day, Subject, Time) and at least two rows of three td cells. Then add an ordered list of three steps and a link to #top.

Stretch challenge

Add a <caption> to the table and make one cell span two columns with colspan="2".

โ† Elements, attributes and text formattingImages, audio, video and embeds โ†’

HTML

More in this module

Keep going in Web Developer Path

Practise the idea

๐Ÿ“Š Play Data Detective

Use mean, median and mode to describe a set of data and compare what each tells you.

Play now

FAQ

Links, lists and tables: common questions

What does the href attribute do?

It holds the address a link points to. Without href, an a tag is not a working link.

What is the difference between ul and ol?

ul is an unordered list shown with bullets, and ol is an ordered list shown with numbers. Both contain li items.

Should I use tables for page layout?

No. Tables are for data. Page layout is done with CSS, which you will learn in the next module.

I am stuck. What can I do?

Press Hint for a nudge, read the message next to each goal, and compare your code with the lesson text. If you still need it, Show answer reveals a model solution. Try to type it yourself rather than copy it.

Does my work get saved?

Your ticks and XP are saved in this browser, and in your account if you log in. The code you type is not stored on a server.

Start a conversation

Enjoying coding? Meet a teacher.

Tell us the learner's age, country and what they would like to build, and we will suggest a class. A parent or guardian can make the enquiry.

  • Tell us the learnerโ€™s age or grade and goals
  • Weโ€™ll suggest a suitable class or learning path
  • Weโ€™ll confirm format, timing and fees with a parent or guardian

For a childโ€™s class, please have a parent or guardian send the enquiry. Avoid sharing passwords or sensitive personal details.

Weโ€™ll use your details only to respond to this request.

Play it, don't just read it

Write some code right now

Free games that need no sign-up. Pick one and play for five minutes.

All free games โ†’
Chat on WhatsApp
Esc

Try