HTML and CSS · Chapter 5 of 12
Semantic HTML
By the end of this chapter you can give a page its landmarks (<header>, <nav>, <main>, <footer>, <aside>), mark up a piece that stands on its own as an <article>, write a date both for people and for programs with <time datetime>, choose <strong> and <em> for what they mean, and say why a page of divs is broken even when every word is on it. 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
- 3 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
Ira has been testing Parda's pages with a screen reader, the program many blind and low-vision people use to hear a page and move around it. Its users rarely listen from the top. They open a list of the page's landmarks (its top, its links, its main content, its end) and jump straight to the one they want, or jump from heading to heading. On Parda's home page that list is empty, so a listener hears the site's name, the tagline and four links before every single page's content.
Datta's launch night page is worse: he built it out of <div>s, with <b> for the headings. Everything you know so far says what text is (a heading, a paragraph, a list, a link). This chapter adds elements that say what a part of the page is.
What you build: 3 tasks
Each task has tests. You write the code in the lab's editor and press Check.
- Task 1
index.html: the site's landmarks
Wrap the parts of the home page in the elements that say what each is, and change nothing else. A header holds the h1 Parda, the tagline Tickets for Pune's own cinemas and stages, and a nav; the nav holds the list of four links, Home, Venues, Shows and Contact (to index.html, index.html#venues, index.html#shows and index.html#contact). A main holds everything from the h2 Twelve venues, one website to the end of Write to us. A footer holds the last paragraph, Parda, Pune. Call 020 4123 1952 or write to help@parda.example.
The page has one header, one nav, one main and one footer. The nav sits inside the header; the header, the main and the footer sit straight inside the body, one after another.
- Task 2
show.html: the show as an article, with times
Give show.html the same header (the h1 Parda, the tagline and the nav of four links) and the same footer as index.html, with a main between them. In the main, an article holds the whole show: its h2 The Last Show at Moti Mahal, its two paragraphs, the h3 Showtimes and the list of times. Each showtime is a time element with a datetime: Fri 4 Apr, 6:30 pm is 2025-04-04T18:30; Sat 5 Apr, 3:00 pm is 2025-04-05T15:00; Sun 6 Apr, 6:30 pm is 2025-04-06T18:30.
The text of each time stays as it is. Keep the page's title, The Last Show at Moti Mahal: Parda.
- Task 3 · interview question
Interview: this-week.html, a page of divs
Datta's this-week.html is all divs, with b for its headings. Fix it so that a header holds the h1 Parda, the tagline in a p, and a nav with the four links (as on index.html); a main holds the h2 Launch night, Fri 4 Apr and the three shows, one p a show; Sold out. is in strong; and a footer holds the last line, Parda, Pune. Call 020 4123 1952 or write to help@parda.example., in a p.
Keep every text and link as it is. No b and no div is left on the page. Keep the page's title, Launch night: Parda.
Ira will ask: it shows every word, so what is wrong with a page of divs?
What you will learn
- Landmarks: <header>, <nav>, <main>, <aside> and <footer>, the parts a screen reader jumps between.
- <section> and <article>: a part of a page with its heading, and a piece that stands on its own.
- <time datetime>: a date and time for people, and the same for programs.
- <strong> and <em>: importance and stress, not bold and italic like <b> and <i>.
- A link or a button: a link goes somewhere; a button does something.
- Div soup: why <div> says nothing.
More in HTML: the structure
Build "Semantic HTML" 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.