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 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 โ
More in this module
Keep going in Web Developer Path
How the web works and your first HTML page
Complete the page: give it the title `My page`, put an `h1` heading inside the body, add two lines of text separated by `<br>`, and add an HTML comment.
Start โ2Elements, attributes and text formatting
Write a paragraph with the id `notes` that contains important text (`strong`), emphasised text (`em`), highlighted text (`mark`) and a subscript (`sub`).
Start โ4Images, audio, video and embeds
Write a figure that contains an image (with `src` and `alt`) and a caption, then an `audio` player with `controls` and a `video` player with `controls`.
Start โ5Semantic page layout
Build the layout: a `header` with an `h1` and a `nav` holding two links, a `main` with a `section` that contains an `article`, an `aside`, and a `footer` with some text.
Start โ6Forms and user input
Build a sign-up form with labelled text, email and password fields, two radio buttons that share the name `level`, a checkbox, a `select` with two `option`s, a `textarea` and a submit button.
Start โPractise the idea
๐ Play Data Detective
Use mean, median and mode to describe a set of data and compare what each tells you.
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
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.
Pick a game
- Bug HunterA Python program prints the wrong answer. Find the one line with theโฆPlay
- Predict the OutputRead a short Python program and choose what it prints. Then watch it runโฆPlay
- Code BuilderThe lines of a Python program are mixed up. Tap them into the rightโฆPlay
- Code JungleWrite real Python to guide Miko the monkey to every banana. 24 levels:โฆPlay