HTML and CSS · Chapter 3 of 12
Lists and tables
By the end of this chapter you can mark up a list as a list (bullets with <ul>, numbers with <ol>, one <li> an item, and a list inside an item), build a table of data with a caption, a header row and rows of cells, and say why a list made of dashes, or a table used to put things side by side, is wrong even when it looks right. Build it in your browser: a real editor and terminal, AI that explains, and tests that tell you when it works.
- Part: HTML: the structure
- 4 tasks
- HTML and CSS
- In the all labs plan
The first 2 chapters of HTML and CSS are free. This one comes with the all labs plan.
Why you need this
The launch is two weeks away and three things on Parda's site are lists or tables in all but name. The home page names twelve venues in three long sentences. Datta wants the steps for booking at a box office on his page, in order. And Ira's design for the launch week is a table: nine showtimes, each with a day, a time, a show, a venue and a price.
Paragraphs cannot do any of it. Twelve names in one sentence are hard to scan, and a screen reader reads them in one breath. Nine showtimes as paragraphs lose their columns: nobody can run a finger down "Time". HTML has elements for exactly these shapes.
What you build: 4 tasks
Each task has tests. You write the code in the lab's editor and press Check.
- Task 1
index.html: the venues as a nested list
Under the h2 Twelve venues, one website, Ira's lines for the venues are plain text. Make them one unordered list (ul) of three items, in this order: Cinemas, Stages and halls, Clubs and lawns. Each item holds the group's name and then an unordered list of its venues inside that same item, one item a venue, in this order. Cinemas: Kala Talkies, Sadashiv Peth; Nilambari Cinema, Kothrud; Moti Mahal Talkies, Camp; Chitra Mandir, Pimpri; Shalini Picture House, Hadapsar. Stages and halls: Rangdeep Studio Theatre, Erandwane; Natya Ghar, Shivajinagar; Kothrud Kala Kendra; Sur Sangam Hall, Deccan. Clubs and lawns: The Attic, Baner; Kattaa Cafe Stage, Viman Nagar; Sahyadri Lawns, Aundh.
A list inside a list goes inside an item, never straight inside the outer list. Each venue's text is exactly as in the starter.
- Task 2
box-office.html: the booking steps, in order
Under the h2 How to book at the box office, make Datta's five steps an ordered list (ol), one item a step, in this order: Find your show on Parda's launch week page.; Come to the venue's box office: it opens an hour before the first show.; Say the show, the time and how many seats you want.; Pay at the window with cash or UPI.; Keep your ticket: you show it at the door.
The list comes right after that h2. Do not type the numbers: the browser numbers the items. Each step's text is exactly as in the starter, full stop included.
- Task 3
shows.html: the launch week as a table
Make the nine showtimes on shows.html one table. Its caption is Launch week, Fri 4 to Thu 10 Apr. Its head (thead) holds one header row of five header cells (th), each with scope="col": Day, Time, Show, Venue, From. Its body (tbody) holds nine rows, one a showtime, in the starter's order, each with five data cells (td) in the same order as the header, holding the values exactly as in the starter's lines, without the | marks.
The first row is Fri 4 Apr, 6:30 pm, The Last Show at Moti Mahal, Moti Mahal Talkies, Camp, ₹130, and the last is Thu 10 Apr, 8:00 pm, Mummy Ka Phone, The Attic, Baner, ₹399.
- Task 4 · interview question
Interview: before-you-come.html, a list that is not one
Datta's before-you-come.html looks right to him, but its tips are lines with dashes and line breaks in one paragraph, and its two ways to reach Parda sit in a table to put them side by side. Fix the page so that the four tips are an unordered list (ul), one item a tip, with no dash at the start and no br: Every box office opens an hour before the first show.; Pay at the window with cash or UPI.; Sahyadri Lawns opens from 5 pm on show days only.; Rangdeep Studio Theatre is closed on Mondays. And so that the page has no table: Write to help@parda.example. and Or call 020 4123 1952. are two paragraphs (p).
Keep the page's title, Before you come: Parda, and the rest of the page as it is.
Ira will ask: it looks like a list, so why does it matter that it is not one?
What you will learn
- <ul>, <ol> and <li>: a list with bullets, a list with numbers, and its items.
- A list inside a list: an inner list goes inside an item.
- What a screen reader gets: "list, 3 items" for a list; one long paragraph for lines with dashes.
- <table>, <caption>, <thead>, <tbody>, <tr>, <th>, <td>: a table of data, its name, its header row and its cells.
- scope="col" and scope="row": which column or row a header cell names.
More in HTML: the structure
Build "Lists and tables" yourself
Parda is launching its first website for Pune's own cinemas and stages. You build it, page by page. A real editor and terminal in your browser, AI that explains, and a Check that says when it works.
The first 2 chapters of HTML and CSS are free. This one comes with the all labs plan.