T1 HTML · Lesson 6
Semantic HTML
Elements chosen for meaning, not looks: the page's header, nav, main and footer, with a skip link; section, article and aside; time, address, quotations, cite, mark and abbr; and boxes that open and close with details and summary.
- say what semantic HTML is, and why it matters to people, browsers and search engines
- build a page from header, nav, main and footer, with a skip link for keyboard users
- choose between section, article and aside, each with its own heading
- mark up dates, addresses, quotations, highlights and short forms with their own elements
- make a box that opens and closes by itself with details and summary
The back cover
Two pages can look exactly alike and still be built very differently. One is a pile of plain boxes. The other names every part: this is the menu, this is the main content, this is a date, this is a quotation. People see no difference, but screen readers, search engines and the next programmer do.
These pages show the elements that name the parts of every page, and the ones that divide its content into articles, sections and side notes. Others say what a piece of text is: a date, an address, a quotation, the name of a work, a short form.
The last part is a box that opens and closes by itself, with no script at all.
Before you start
The story: Every box says box
Wren stops in front of the Assay Office's new panel and frowns. To everyone else it looks perfect: neat, bright, well built. To her listening-glass it is one long run of boxes. There is no way to tell the menu from the notice, or to skip to what matters.
"Every box says box," she tells you. "Not one of them says what it is for. I have to listen to the whole menu, every time, before I reach the news."
The Assay Office's clerk shrugs. "It looks right," he says.
Lessons 2 to 5 gave you the elements for text, links, pictures, lists, tables and forms. This lesson is about the boxes that hold whole parts of a page: its top, its menu, its main content, its side notes, its bottom. Choosing them well is called semantic HTML, HTML that says what each part means. It builds on these ideas; each has a tiny example.
| What you already know | A tiny example | Where it comes back |
|---|---|---|
| A tag says what content is, not how it looks. | strong means important; bold is only how it usually looks. | This whole lesson is that idea, for the large parts of a page. |
| div and span are boxes with no meaning. | A div groups a product card; it says nothing about it. | Semantic boxes group in the same way, and say what the group is. |
| One h1, and no skipped levels. | h1 Asha Stores, then h2 Vegetables. | Each part of a page gets headings in the same outline. |
| Screen readers jump around a page. | They jump from link to link, or heading to heading. | They also jump straight to a page's menu or main content. |
| id and links to a part of a page. | <a href="#prices"> jumps to the element with id prices. | A "Skip to main content" link uses exactly that. |
| figure and figcaption. | A photo with its caption, joined. | They are semantic elements too. |
| Attributes switched on by being written. | checked, required. | open opens a details box from the start. |
| A newspaper's page. | The masthead at the top, sections, articles, a sidebar, the small print at the bottom. | A web page has the same parts, each with its own element. |
| The browser fills in what you leave out. | It adds a tbody to a table by itself. | It also adds quotation marks around a q, through its styles. |
By the end of this lesson you will be able to:
- say what semantic HTML is, and why it matters to people, browsers and search engines;
- build a page from header, nav, main and footer, with a skip link for keyboard users;
- choose between section, article and aside, each with its own heading;
- mark up dates, addresses, quotations, highlights and short forms with their own elements;
- make a box that opens and closes by itself with details and summary.
In one line
Semantic HTML chooses each box for what it means; you need lesson 2's idea that tags say what content is, and lesson 3's links to an id.
Meaning, not looks
At a glance
Semantic elements look exactly like div on the screen, but each one says what its part is for. A div says only: a box. A nav says: a box of links for getting around. That meaning is read by more than eyes.
Screen readers jump between these named parts, called landmarks. Search engines use them to find the real content. The browser's own tools, other developers, and you in six months read them too. So each part is chosen by its meaning, and div is kept for the cases where nothing else fits.
Take a guess: Two pages look exactly alike: can a screen reader still tell them apart?
Picture the plan of a flat drawn two ways. On one plan, every room is labelled Room: Room, Room, Room, Room. On the other, the rooms say Kitchen, Bedroom, Bathroom, Balcony. The walls are the same; the flat is the same. But only the second plan tells a plumber where the pipes go, or a guest where to find the bathroom.
A page built only from div elements is the first plan. Every part is a box, and no box says what it is. A page built with semantic elements is the second plan: each box is named for its job.
HTML in which each element is chosen for what its content means, not for how it looks. The word semantic comes from the Greek for "meaning".
Two pages that look the same
Built from div only
<div class="top">Asha Stores</div>
<div class="menu"><a href="/">Home</a> <a href="/offers">Offers</a></div>
<div class="content">Fresh vegetables every morning.</div>
<div class="bottom">Shop 4, MG Road, Pune</div>
Checked in Chrome
- four boxes, none of which says what it is
Built from semantic elements
<header>Asha Stores</header>
<nav><a href="/">Home</a> <a href="/offers">Offers</a></nav>
<main>Fresh vegetables every morning.</main>
<footer>Shop 4, MG Road, Pune</footer>
Checked in Chrome
- header and nav draw exactly alike
- and so do main and footer: no element changes the look
- but each box now says what it is
Run both. They look exactly the same: the checks ask the browser for each box's display, font size, weight and margin, and find nothing different. The semantic elements change no looks at all. They change only what the page says about itself.
A memory aid
div says "a box"; a semantic element says "a box, and here is what it is for". When an element exists for the job, use it; use div only when none fits.
Who reads the meaning?
If nothing changes on the screen, who is it for? Four readers, none of them looking at the colours.
- Screen readers. A blind visitor can ask for a list of the page's parts and jump straight to the menu or the main content, instead of listening to the whole top of the page on every visit.
- Search engines. They learn which part is the real content and which is the menu repeated on every page.
- The browser's own tools. A phone browser's reader view, which shows an article without clutter, finds the article by its element.
- Other developers, and you in six months.
<nav>explains itself;<div class="x7">does not.
Screen readers call these parts landmarks, like the landmarks you give in directions: "turn left at the temple". Each semantic element is announced by a landmark name.
| Element | What it means | A screen reader announces it as |
|---|---|---|
<header> | the top of the page: the name, the logo | banner |
<nav> | a block of main links for getting around | navigation |
<main> | the page's own content, which no other page shares | main |
<aside> | a side note, related but not part of the main flow | complementary |
<footer> | the bottom: contact details, copyright, small print | content info |
Worked example 1
A news site's article page has five parts. At the top, the paper's name and logo, then a row of links (Home, India, Sport, Business). Then the article itself, with a box of "Most read today" links on the right. At the bottom, the address and copyright. Name the element for each part.
What we have: five parts of a page, each described by its job
What we need: the semantic element for each
The plan: for each part, ask what job it does, then find the element named for that job
- The paper's name and logo at the top: the page's header, so header.
- The row of main links: for getting around, so nav.
- The article: the content no other page shares, so main (the next section adds an article inside it).
- "Most read today": related, but not part of the article, so aside.
- The address and copyright: the small print, so footer.
header, nav, main, aside, footer, in that order.
Check: every part found an element named for its job, so no div was needed.
A path that fails: Choosing by position: "it is at the top, so header". A row of links at the top is still a nav; what decides is the job, not the place.
When you are stuck: choosing semantic elements
Describe the part in a few words of plain English, then look for an element with that name.
If no element fits its job, a div is right; semantic HTML does not ban div.
Remember the elements change no looks: choose by meaning, and leave the looks to CSS.
Your turn
Does changing a div to a nav change how the page looks?Tap to reveal
- Look at the checks of the two blocks.
No: they draw exactly alike; only the meaning changes.
What do screen readers call the parts that semantic elements mark?Tap to reveal
- The word for points you give in directions.
Landmarks.
Which element holds the content that no other page of the site shares?Tap to reveal
- It is the page's own content.
<main>.
Did you know?
HTML5 named the parts of a page
HTML5 became a W3C Recommendation on 28 October 2014. To enrich the meaning of documents, it added new page structure elements such as main, section, article, header, footer, aside, nav and figure. Some of them replace common uses of the plain div, such as nav for a website's navigation block.
Why it fits here: The header, nav, main and footer of this lesson are those elements, made to give each part of a page a name.
Sources: W3C: HTML5, W3C Recommendation 28 October 2014; Wikipedia: HTML5
The div is the element of last resort
The HTML standard itself gives the div a warning. Authors are strongly encouraged to view the div element as an element of last resort, for when no other element is suitable. It explains why: using more appropriate elements instead of div leads to better accessibility for readers and easier maintenance for authors.
Why it fits here: This is the rule of this topic in the standard's own words: meaning first, and div only when nothing fits.
In one line
Semantic elements look exactly like div, but each says what its part is for. Screen readers jump between these landmarks, and search engines find the real content. Choose by meaning, and use div only when nothing fits.
The parts of every page: header, nav, main, footer
At a glance
Most pages share one shape, the way most letters do: a top, a middle and a bottom. A header holds the site's name and the nav, the box of main links. One main holds the page's own content, and a footer holds the small print at the bottom.
A page has exactly one main. A skip link, placed first and pointing at the main's id, lets a keyboard user jump past the menu straight to the content. Without it, they would press Tab through every menu link on every page.
Take a guess: Why would someone using only a keyboard want to skip the menu?
Most pages on the web share one shape, like most letters share one shape. A top with the site's name, a menu, the page's own content, and a bottom with the small print. Four elements mark those four parts.
A page with its four landmarks
<header>
<h1>Asha Stores</h1>
<nav>
<ul>
<li><a href="/">Home</a></li>
<li><a href="/offers">Offers</a></li>
<li><a href="/contact">Contact</a></li>
</ul>
</nav>
</header>
<main>
<h2>Fresh today</h2>
<p>Tomatoes, onions and methi, in by 7 am.</p>
</main>
<footer>
<p>Shop 4, MG Road, Pune. Open 8 am to 9 pm.</p>
</footer>
Checked in Chrome
- the site's name sits in the header
- the menu is a nav holding a list of three links
- one main
- the small print sits in the footer
Go through it part by part.
- header holds what starts the page: here the h1 with the shop's name, and the menu.
- nav holds the main links for getting around the site. A menu is a list of links whose order does not matter much, so it is a ul, as in lesson 4; CSS later lays it out in a row.
- main holds this page's own content, the part that changes from page to page.
- footer holds what ends the page: the address, the hours, the copyright.
One main, and only one
A page has exactly one main: its own content. The browser does not stop you writing two, and shows no error. But a screen reader's "jump to main content" then has two places to go, and the point of the landmark is lost.
You may wonder: should every group of links be a nav? No. nav is for the main ways of getting around: the site's menu, a table of contents. A few links inside a paragraph, or the links in a footer, need no nav of their own.
A skip link: inclusive navigation
Some visitors cannot use a mouse. They move through a page with the Tab key, one link at a time. On a site with a menu of 30 links, they would press Tab 30 times on every page before reaching the content. A skip link saves them: the very first link on the page jumps straight to the main content.
<a href="#content">Skip to main content</a>
<header>
<nav><a href="/">Home</a> <a href="/offers">Offers</a> <a href="/contact">Contact</a></nav>
</header>
<main id="content">
<h2>Fresh today</h2>
</main>
Checked in Chrome
- the first link on the page is the skip link
- it jumps to the main element
It is a link to an id, exactly as in lesson 3: href="#content" jumps to the element with id content, here the main. Big sites often hide the skip link until it is reached with Tab, so it does not clutter the page for mouse users; the CSS step shows how. Designing a page so that everyone can move through it, whatever they use, is called inclusive navigation.
Worked example 2
Write the skeleton of a school's page. The header holds the h1 Green Valley School and a nav of two links (Admissions, Results). The main content holds the h2 Admissions open. The footer holds the line Phone: 020 2567 1234.
What we have: the four parts and what goes in each
What we need: a page built from header, nav, main and footer
The plan: header first, holding the h1 and the nav (its links in a ul); then main; then footer
<header>
<h1>Green Valley School</h1>
<nav>
<ul>
<li><a href="/admissions">Admissions</a></li>
<li><a href="/results">Results</a></li>
</ul>
</nav>
</header>
<main>
<h2>Admissions open</h2>
</main>
<footer>
<p>Phone: 020 2567 1234</p>
</footer>
Checked in Chrome
- the school's name in the header
- a nav of two links
- the main content
- the phone number in the footer
header (h1 and nav), main (h2), footer (the phone line).
Check: each check finds its content inside the right landmark.
When you are stuck: a page's landmarks
Sort the page into four piles: what starts it, the main links, its own content, what ends it.
Check there is exactly one main.
Put a skip link first, pointing at the main's id.
Your turn
How many main elements should a page have?Tap to reveal
- It holds the page's own content.
Exactly one.
Should every group of links be a nav?Tap to reveal
- nav marks the main ways of getting around.
No: only the main menus and tables of contents.
Who does a skip link help most?Tap to reveal
- Think of a visitor using only the Tab key.
Keyboard users, who would otherwise tab through every menu link first.
Did you know?
Skipping is a rule of the web's guidelines
The W3C's Web Content Accessibility Guidelines include a rule called Bypass Blocks, success criterion 2.4.1, at level A, the minimum level of conformance. Its goal is that users can more easily navigate by keyboard, and what it asks is short: provide a means of skipping repeating content. One technique it lists is a link at the top of each page that goes straight to the main content.
Why it fits here: The skip link of this topic is that very technique, placed first on the page.
Sources: W3C WAI: Understanding Success Criterion 2.4.1, Bypass Blocks; W3C: Web Content Accessibility Guidelines 2.2
How often people use landmarks
WebAIM asked screen reader users in 2023 and 2024 how often they move through a page by its landmarks. 17.9% said whenever they are available, and 13.9% often. Frequent use had fallen steadily from 43.8% in 2014 to 25.6% in 2021, and in 2024 it rose again, to 31.8%.
Why it fits here: The header, nav, main and footer of this topic are those landmarks, and nearly a third of these readers use them often.
In one line
Most pages are a header (the name and the nav of main links), one main (the page's own content) and a footer (the small print). A skip link first, to the main's id, lets keyboard users jump past the menu.
Inside the main: section, article and aside
At a glance
Inside the main, three elements divide the content, like the parts of a magazine. An article is a piece that stands alone, one that could be torn out and handed to a friend: a news story, a product card, a comment. A section is a chapter of something larger, with its own heading.
An aside is a side note that the piece could lose without harm, such as a box of related links. A header or footer inside an article belongs to that article. Where only looks are needed, div is still right.
Take a guess: A product card on a shop page: could it be torn out and still make sense on its own?
Open a magazine. It is split into sections: News, Sport, Food. Each section holds articles, each of which you could tear out and hand to a friend, and it would still make sense. And here and there, a box on the side: a tip, a fact, a quote, related to the article but not part of its flow. HTML has an element for each.
| Element | It is | Ask yourself | Examples |
|---|---|---|---|
<section> | one part of something bigger, on one theme, with its own heading | Is this a chapter of the page? | Ingredients and Method of a recipe; the About and Contact parts of a page |
<article> | a complete piece that makes sense on its own | Could I share or print this alone? | a news story, a blog post, a recipe, a product card, a comment |
<aside> | a side note: related, but not part of the main flow | Could I remove it and the piece still read well? | a tip box, related links, a glossary note |
A recipe page
<main>
<article>
<header>
<h2>Poha in 15 minutes</h2>
<p>By Meera, Indore</p>
</header>
<section>
<h3>Ingredients</h3>
<ul><li>2 cups poha</li><li>1 onion</li><li>Peanuts, turmeric, salt</li></ul>
</section>
<section>
<h3>Method</h3>
<ol><li>Rinse the poha.</li><li>Fry the onion and peanuts.</li><li>Mix, and steam for 2 minutes.</li></ol>
</section>
<aside>
<p>Tip: a squeeze of lemon at the end lifts the whole dish.</p>
</aside>
</article>
</main>
Checked in Chrome
- the recipe is one article in the main
- each section has its own heading
- the tip sits in an aside inside the article
- the article has its own header with its title
Read it from the outside in. The article is the whole recipe: it could be shared on WhatsApp alone and still make sense. Inside it, two sections, Ingredients and Method, are its chapters, each with an h3. The aside holds the tip, which the recipe would survive without.
The article also has its own header, with the recipe's title and its writer. A header or footer inside an article belongs to that article, not to the whole page. A screen reader announces only the page's own header and footer as landmarks.
Sections are not boxes for styling
Writing a section just to put a coloured background behind something. A section is a chapter with a heading. A box needed only for looks is a div, which is still the right element when no meaning fits.
Headings inside the parts
Every section and article should start with a heading, which names it. You might expect an h1 inside a section to shrink by itself. It does not: browsers draw it at the same size as any h1. So choose the levels as lesson 2 taught, by the outline: the page's h1, then h2 for its main parts, h3 inside those.
Worked example 3
A shop's offers page shows three products, each with a name, a price and a Buy link. Should each product be a section, an article or a div?
What we have: three product cards with the same parts
What we need: the right element for one card, and why
The plan: ask the article question: could one card be shared alone and still make sense?
- A card shared alone, "Toor dal, 1 kg, ₹180, Buy", still tells a friend everything. So it passes the article test.
- It is not a chapter of one bigger piece, so section is the wrong fit.
<main>
<h1>Offers</h1>
<article><h2>Toor dal, 1 kg</h2><p>₹180</p><a href="/buy/dal">Buy</a></article>
<article><h2>Basmati rice, 5 kg</h2><p>₹650</p><a href="/buy/rice">Buy</a></article>
<article><h2>Sugar, 1 kg</h2><p>₹45</p><a href="/buy/sugar">Buy</a></article>
</main>
Checked in Chrome
- three products, three articles
- each with its own heading and Buy link
An article for each product, each with its own h2.
Check: each card would make sense printed on its own, which is exactly what article means.
A path that fails: Making each card a section "because it is a part of the page". A section is a chapter of something bigger; three separate products are three complete pieces, not three chapters.
When you are stuck: section, article or aside
Ask the three questions in order: could it stand alone (article)? Is it a chapter of something (section)? Is it a side note (aside)?
If none fits and the box is only for looks, use a div.
Give every section and article a heading.
Your turn
A blog post's comments: is each comment an article or a section?Tap to reveal
- Does one comment make sense on its own?
An article: each comment is a complete piece.
Where does a header inside an article belong?Tap to reveal
- To the page, or to the article around it?
To the article, not to the page.
Does an h1 inside a section shrink by itself?Tap to reveal
- Look at what this section says about headings.
No: choose heading levels by the outline.
Did you know?
An article can travel alone
The HTML standard defines the article element as a self-contained composition in a document, page, application or site, intended to be independently distributable or reusable, for example in syndication. Its examples include a forum post, a magazine or newspaper article, a blog entry, a product card and a user-submitted comment.
Why it fits here: The test of this topic, whether a piece could be torn out and still make sense, is the standard's own test.
An aside on the stage
On a stage, an aside is a line spoken to the audience that the other actors supposedly do not hear. A dictionary also gives the word a second meaning: a digression, a turn away from the main subject. HTML uses aside for a part of a page that is only loosely related to the content around it, and could be seen as separate from it.
Why it fits here: The aside of this topic is that kind of remark: useful, but the main piece makes sense without it.
Sources: American Heritage Dictionary: aside; Wiktionary: aside; HTML Standard (WHATWG): the aside element
In one line
An article is a piece that stands alone, a section a chapter with its own heading, and an aside a side note the piece could lose. A header or footer inside an article belongs to it, and div stays right when only looks are needed.
Text that says what it is
At a glance
Some elements say what a piece of text is. The time element holds a date or a time, and its datetime attribute gives a machine form, such as 2026-11-01. The address element holds contact details. A blockquote holds a long quotation and a q a short one, and the browser adds the quotation marks to a q.
A cite holds the title of a work, such as a book. mark highlights words, like a highlighter pen. An abbr holds a short form, with the full words in its title attribute.
Take a guess: Why might a date need a second, machine form, as well as the words people read?
Lesson 2 marked words as important (strong) or stressed (em). A few more elements say what a piece of text is: a date, an address, a quotation, the name of a book, a highlight, a short form. Each one helps a machine understand what a person sees at a glance.
A date or time: time
People write dates in many ways: 1 November, 1/11, Nov 1st. A program cannot be sure what "1/11" means: the first of November, or the eleventh of January? The time element keeps the friendly words for people and adds an exact form for machines, in its datetime attribute.
<p>The sale starts on <time datetime="2026-11-01">1 November</time> at <time datetime="09:00">9 am</time>.</p>
Checked in Chrome
- the date, for machines: 2026-11-01
- the date, for people: 1 November
The machine form is always year, month, day, with hyphens: 2026-11-01. Times are hours and minutes on the 24-hour clock: 09:00, or 21:30 for half past nine at night. A calendar app or a search engine can read these without guessing.
Contact details: address
The address element holds the contact details for the page or the article it sits in: a postal address, a phone number, an email. It is not for any address that happens to be mentioned in the text, only for "how to reach us".
<footer>
<address>
Asha Stores, Shop 4, MG Road, Pune 411001<br>
<a href="tel:+919876543210">98765 43210</a>
</address>
</footer>
Checked in Chrome
- the contact details, with a phone link, in the footer
- the browser shows it in italics, which CSS can change
Quotations: blockquote and q
A quotation is someone else's words. A long one, a paragraph or more, goes in a blockquote, a block that the browser pushes in from the left. A short one inside a sentence goes in a q, and the browser adds the quotation marks itself.
<blockquote cite="https://www.example.com/speeches/1">
<p>Arise, awake, and stop not till the goal is reached.</p>
</blockquote>
<p>As the shopkeeper said, <q>Fresh stock comes in at 7</q>.</p>
Checked in Chrome
- the blockquote is pushed in 40 pixels
- the browser draws the opening quotation mark
- so you never type the marks yourself
The words in the blockquote are Swami Vivekananda's. The cite attribute on a blockquote holds the address of where the words come from; it is not shown, but tools can follow it. The q's marks are drawn by the browser's styles, not typed: the third check confirms the text itself holds none. Typing them as well would show two pairs.
Names of works: cite
The cite element (not to be mixed up with the attribute) holds the title of a work: a book, a film, a song, a paper. Browsers show it in italics.
<p>My favourite book is <cite>Malgudi Days</cite> by R. K. Narayan.</p>
Checked in Chrome
- the title of the book is a cite
- shown in italics
A highlight: mark
The mark element is a highlighter pen: it marks words that matter for the reader right now, such as the words they searched for. Browsers paint it yellow.
<p>Results for "dal": Toor <mark>dal</mark>, 1 kg; Moong <mark>dal</mark>, 500 g.</p>
Checked in Chrome
- both matches of the search are marked
- painted yellow, like a highlighter
How is mark different from strong? strong says the words are important always; mark says they are relevant to what the reader is doing now. Search for "rice" instead, and the marks move.
Short forms: abbr
A short form such as GST or UPI is clear to some readers and a puzzle to others. The abbr element (for abbreviation) holds the short form, and its title attribute the full words.
<p>Prices include <abbr title="Goods and Services Tax">GST</abbr>.</p>
Checked in Chrome
- the full form, for anyone who asks
- the browser underlines it, as a sign that more is there
Hovering over it with a mouse shows the full form. On a phone there is no hover, so the first time a short form appears, also write it out in the text: "Goods and Services Tax (GST)".
Worked example 4
Mark up this sentence: The admission form for Class 11 must reach the school office by 15 June 2027, says the Principal's notice. Show the date in a form machines can read.
What we have: a sentence with a date in it
What we need: a time element with the friendly words and the exact datetime
The plan: keep 15 June 2027 for people; write datetime as year, month, day with hyphens
- Year 2027, month June is 06, day 15: so 2027-06-15.
<p>The admission form for Class 11 must reach the school office by <time datetime="2027-06-15">15 June 2027</time>, says the Principal's notice.</p>
Checked in Chrome
- the machine form is 2027-06-15
- people still read 15 June 2027
<time datetime="2027-06-15">15 June 2027</time>.
Check: the month is written with two digits, 06, and the order is year, month, day, so no program can misread it.
Worked example 5
A bookshop's page quotes a review of the novel The Guide by R. K. Narayan. The review is two sentences long: A gentle, funny book. I read it in one sitting. Below it, a line says that one reader called it "perfect for a train journey". Mark up both quotations and the book's title.
What we have: a long quotation, a short one inside a sentence, and the title of a book
What we need: the right element for each
The plan: a review of two sentences is a block, so blockquote; the few words inside a sentence are a q; the title is a cite
<p>Reviews of <cite>The Guide</cite> by R. K. Narayan:</p>
<blockquote>
<p>A gentle, funny book. I read it in one sitting.</p>
</blockquote>
<p>One reader called it <q>perfect for a train journey</q>.</p>
Checked in Chrome
- the title is a cite
- the review is a blockquote
- the short quotation is a q, with no typed marks
cite for The Guide, a blockquote for the review, and a q for the short quotation.
Check: the checks find each piece in its element, and the q's text has no marks of its own.
A path that fails: Putting the short quotation in a blockquote too. A blockquote is a block, so it would break the sentence onto lines of its own, and the reader would lose the flow.
When you are stuck: semantic text
Ask what the text is: a date (time), contact details (address), someone's words (blockquote or q), a title (cite), a highlight (mark), a short form (abbr).
Never type the quotation marks around a q: the browser adds them.
Write datetime as year-month-day, with two digits for the month and the day.
Your turn
Write the machine form of 5 August 2027 for a time element.Tap to reveal
- Year, month, day, with hyphens and two digits each for month and day.
2027-08-05.
Who adds the quotation marks around a q?Tap to reveal
- Look at the third check of the quotation block.
The browser, through its styles.
When is mark the right element, rather than strong?Tap to reveal
- One is important always; one is relevant now.
When the words matter for what the reader is doing now, such as matches of their search.
Did you know?
The element that was dropped and brought back
On 30 October 2011 Bruce Lawson wrote, with great sadness, that the time element had been dropped from HTML, replaced by a more generic data element. The editor of the standard, Ian Hickson, had explained the change. Developers protested, not least because WordPress and GitHub were using time more and more. In the minutes of a meeting on 3 November 2011, the chairs of the W3C's HTML working group decided against dropping time, and it was restored.
Why it fits here: The time element of this topic was saved because people were already using it to say what a date is.
Sources: Bruce Lawson: Goodbye HTML5 <time>, hello <data>!; Creative Bloq: W3C restores time element to HTML5
Dates written the international way
The datetime of a time element uses formats that the HTML standard means to be subsets of ISO 8601, an international standard for dates and times. ISO 8601 was first published in 1988. It gives one clear way to write dates, especially to avoid misreading numbers passed between countries that write dates in different orders. Its values run from the largest unit of time to the smallest: year, month, day, hour, minute, second. So 2026-11-01 can only mean 1 November 2026.
Why it fits here: The datetime of this topic uses that order, so every program reads the date the same way.
Sources: HTML Standard (WHATWG): dates and times; Wikipedia: ISO 8601
Two short-form elements became one
HTML 4.01 had two elements for short forms: abbr, for forms such as WWW and HTTP, and acronym, for forms such as radar. Today's HTML standard lists acronym among its entirely obsolete elements, which must not be used by authors, with one instruction: use abbr instead. Its abbr element now represents an abbreviation or acronym.
Why it fits here: The abbr of this topic is the element that survived, and it now covers every short form.
Sources: W3C: HTML 4.01 Specification, phrase elements; HTML Standard (WHATWG): obsolete features; HTML Standard (WHATWG): the abbr element
In one line
The time element gives a date a machine form (datetime="2026-11-01"), and address holds contact details. A blockquote or a q holds a quotation, and the browser adds a q's marks. A cite holds a title, mark a highlight, and abbr a short form with its full words in title.
A box that opens and closes: details and summary
At a glance
A details element is a box that opens and closes by itself, like a folded train timetable. Its first child, summary, is always shown, and clicking it opens or closes the rest. The open attribute starts it open.
No script is needed. The browser itself makes it work with the mouse, the keyboard and screen readers. A box built with a script has to do all of that by hand, and can easily miss a part. Pages use it for answers, notes and long lists that would crowd the screen.
Take a guess: A box that opens and closes: does it need JavaScript?
Think of a train timetable folded in a pocket. The cover says "Pune to Mumbai, all trains"; you unfold it only when you need the times. Many pages need the same: questions whose answers stay folded away until someone wants one. HTML can do this by itself, with no script at all.
A details element is a box that opens and closes. Its first child, a summary, is the line always shown, like the timetable's cover; clicking it opens or closes the rest.
<details>
<summary>What are the delivery charges?</summary>
<p>Free above ₹499; ₹40 below that.</p>
</details>
Checked in Chrome
- the box starts closed
- so the answer is hidden
- a click on the question opens it
- and the answer shows
The checks do what a visitor does. First they find the box closed and the answer hidden. Then they click the summary, as a finger would, and find the box open and the answer showing. The browser also draws a small triangle beside the summary, pointing right when closed and down when open.
You have already met this box in this course: every "Your turn" question you tap to reveal is a details element with a summary.
Open from the start: open
The attribute open, switched on by being written, starts the box open. The visitor can still close it.
<details open>
<summary>Opening hours</summary>
<p>8 am to 9 pm, every day but Sunday.</p>
</details>
Checked in Chrome
- the box starts open
- so its content shows at once
Why not build it with a script?
Before details existed, people built opening boxes from div elements and JavaScript. Those often failed people: the Tab key could not reach them, and screen readers did not say whether they were open or closed. The details element does all of that by itself. The browser makes the summary reachable with Tab, opens it with the Enter key, and tells screen readers "collapsed" or "expanded". This is semantic HTML again: the right element brings its behaviour with it.
A common mistake
Putting important information only inside a closed details. Some visitors never open it, and printed pages can leave it folded. Keep anything everyone must read, such as a price or a deadline, outside the box.
Worked example 6
A school's admissions page has three questions: What is the age limit for Class 1? (6 years by 31 March), Is there an entrance test? (No), When do forms close? (15 June). Write them as boxes that open, with the first one open from the start.
What we have: three questions, each with a short answer, the first to start open
What we need: three details elements with summaries
The plan: one details per question; the question in the summary, the answer in a p after it; open on the first
<details open>
<summary>What is the age limit for Class 1?</summary>
<p>6 years by 31 March.</p>
</details>
<details>
<summary>Is there an entrance test?</summary>
<p>No.</p>
</details>
<details>
<summary>When do forms close?</summary>
<p><time datetime="2027-06-15">15 June</time>.</p>
</details>
Checked in Chrome
- three boxes
- each starts with its question
- only the first starts open
Three details, each a summary and a p; open on the first.
Check: the last check reads the three boxes in order: open, closed, closed.
When you are stuck: details and summary
The summary must be the first thing inside the details; everything after it is what folds away.
To start a box open, write open on the details, not on the summary.
Keep must-read information outside the box.
Your turn
Which element holds the line that stays shown when a details box is closed?Tap to reveal
- It sums up what is inside.
<summary>.
How do you make a details box start open?Tap to reveal
- One attribute, written with no value.
Write open on the details element.
Why is details better than a box built from div and a script?Tap to reveal
- Think of the Tab key and screen readers.
Because the browser makes it work for everyone: it can be reached with Tab, opened with Enter, and screen readers say whether it is open.
Did you know?
Two ways to build an accordion
The W3C's guide to accessible widgets describes the accordion: a vertically stacked set of headings that reveal or hide their sections of content. Built with a script, it has to handle the keyboard itself. Enter or Space on the heading of a closed panel opens that panel, and Tab moves focus to the next focusable element. The HTML standard also lets several details elements share a name: opening one member of the group closes the others.
Why it fits here: The details element of this topic is the way without a script: the browser opens and closes it by itself.
Sources: W3C WAI ARIA Authoring Practices: Accordion Pattern; HTML Standard (WHATWG): the details element
The triangle is a list marker
The small triangle beside a summary is a list marker, of the same family as the dot of a bulleted list. The HTML standard's default style makes a details element's first summary a list item, with the marker disclosure-closed. When the box is open, the marker becomes disclosure-open. The CSS standard suggests a small triangle pointing right for the first and one pointing down for the second.
Why it fits here: The summary in this topic shows that triangle, and it turns as the box opens because the browser swaps one marker for the other.
Sources: HTML Standard (WHATWG): rendering of details and summary; W3C: CSS Counter Styles Level 3
In one line
A details element is a box that opens and closes by itself: its first child, summary, is always shown and opens it. The open attribute starts it open, and the browser makes it work with the keyboard and screen readers.
Where it is used
Open almost any well-built site and look at its HTML: these elements are the skeleton of the modern web.
| What you learned | Where it is used | A real example |
|---|---|---|
| header, nav, main, footer | every page of a well-built site | a bank's site: the logo and menu in the header, the account pages in main, the regulator's notice in the footer |
| the skip link | sites that care about keyboard users | government sites, which must be usable by everyone, often start with "Skip to main content" |
| article | news stories, blog posts, product cards, comments | a news site's home page: each story preview is an article |
| section and aside | long pages split into chapters, with side notes | an encyclopedia article's sections, and its box of related topics |
| time | events, posts, deadlines | a cinema's show times, which a phone can offer to add to its calendar |
| address | contact details | the footer of a clinic's page |
| blockquote, q, cite | reviews, quotations, references | a book shop's page quoting a review, with the book's title in a cite |
| mark | search results | a site's search page highlighting your words in each result |
| details and summary | FAQs, settings, long optional notes | a delivery app's help page of questions that open one by one |
Mistakes and debugging
None of these shows on the screen, which is why they survive so long. They show only to the readers who cannot see the colours.
1. A page made only of div
<div class="header">Asha Stores</div>
<div class="content">Fresh today</div>
Checked in Chrome
- (the slip: no landmarks, so a screen reader has nowhere to jump)
The fix: the class names already say what each part is; use the elements with those names: <header>, <main>.
2. Two main elements
<main>Offers</main>
<main>New arrivals</main>
Checked in Chrome
- (the slip: two mains, and the browser says nothing)
The fix: one main holding both, each part a section with its own heading.
3. A section with no heading
A section is a chapter, and a chapter has a title. Without a heading, a screen reader's list of the page's parts shows a nameless region. The fix: start every section with a heading, or use a div if it is not a chapter at all.
4. Quotation marks typed around a q
<p>She said <q>"Chai is ready"</q>.</p>
Checked in Chrome
- (the slip: typed marks and the browser's own marks, so two pairs show)
The fix: leave the marks out; the browser draws them.
5. Elements chosen for their looks
A blockquote used only to push some text in from the left, or mark used only for a yellow background. A screen reader then announces a quotation that is not one. The fix: choose by meaning, and get the look from CSS.
6. A date with no machine form
Writing "1/11" as plain text, which one program reads as the first of November and another as the eleventh of January. The fix: <time datetime="2026-11-01">1 November</time>.
The debugging corner: see the page as a screen reader does
In Chrome's DevTools (F12), open the Elements panel and find its Accessibility pane. It shows each element's role, the name a screen reader would say for it, such as banner, navigation, main, and its full outline of landmarks and headings. Reading a page through that pane finds most semantic slips at once.
Quick card
The lesson on one card.
Every element of the lesson
<a href="#content">Skip to main content</a>
<header>
<h1>Asha Stores</h1>
<nav><ul><li><a href="/">Home</a></li><li><a href="/offers">Offers</a></li></ul></nav>
</header>
<main id="content">
<article>
<h2>Diwali sale</h2>
<p>From <time datetime="2026-11-01">1 November</time>: <mark>10% off</mark> all sweets, <abbr title="Goods and Services Tax">GST</abbr> included.</p>
<blockquote><p>Best kaju katli in Pune.</p></blockquote>
<p>As our customers say, <q>worth the queue</q>.</p>
<aside><p>Tip: order by 30 October for delivery.</p></aside>
</article>
<details>
<summary>Delivery charges</summary>
<p>Free above ₹499.</p>
</details>
</main>
<footer>
<address>Shop 4, MG Road, Pune 411001</address>
</footer>
Checked in Chrome
- the skip link reaches the one main
- header with its nav, footer with its address
- an article with its heading
- the date in its machine form
- the details box starts closed
| Element | What it is |
|---|---|
<header>, <footer> | what starts and what ends the page (or an article) |
<nav> | the main links for getting around, often a ul |
<main> | the page's own content: exactly one |
<a href="#content"> | the skip link, first, to the main's id |
<article> | a piece that makes sense on its own |
<section> | a chapter of something bigger, with its own heading |
<aside> | a side note the piece could lose |
<time datetime> | a date or time, with its machine form |
<address> | contact details |
<blockquote>, <q>, <cite> | a long quotation; a short one (marks added); a work's title |
<mark>, <abbr title> | a highlight for now; a short form with its full words |
<details>, <summary> | a box that opens and closes; its always-shown line |
The story: Nothing changed, everything did
You do not change a single thing anyone can see. You only rename the boxes for their jobs: the top of the panel, the menu for getting around, the main notice, the side notes, the small print at the bottom. You add one small marker at the very start that jumps straight to the main notice.
Wren lifts her listening-glass. This time it says menu, main and article, and she jumps past the menu in one move. "Now it looks right to me too," she says. The clerk stares. "But nothing changed," he says. "Everything did," says Wren.
Reagents gathered: semantic HTML, landmark, main, article, skip link.
Sources
- MDN Web Docs (Prose CC BY-SA 2.5 or later; code samples added since 2010-08-20 CC0 (its licensing page, read 2026-10-26); reused with credit)
- HTML Living Standard (WHATWG) (CC BY 4.0: "Copyright WHATWG (Apple, Google, Mozilla, Microsoft). This work is licensed under a Creative Commons Attribution 4.0 International License" (its acknowledgements page, read 2026-10-26); reused with credit)