The Blue Cup's pages now have a header with navigation, a shared footer and their content organised into section, article and aside. But a key piece is missing: nothing indicates where the main content of each page begins and ends, the content that makes it different from the others. That is the job of the main element. In this lesson you will study it together with another very useful pair, figure and figcaption, which are used to present illustrative content (a photo, a video, a table, a code fragment or a quotation) together with its caption. You will learn what goes inside main and what stays outside, why there can only be one visible, when an image deserves a figure and when a plain img is enough, and how to express a quotation with its author. By the end, every page will have its main, the gallery will have photos with captions and the reviews on the home page will be properly attributed quotations.
Contents
main: the main content of the page- What goes inside
mainand what doesn't - A preview: the "Skip to content" link
figureandfigcaption: illustrative content with its caption- What can go in a
figure figureversus a plainimg- Project:
mainon every page, the gallery and the reviews
main: the Main Content of the Page
The main element represents the main content of the document: what is unique to that page and is its reason for existing. Everything that is repeated across several pages (header, menu, footer) stays outside.
<body>
<header>
<!-- logo and menu: repeated on every page -->
</header>
<main>
<h1>Our menu</h1>
<!-- content specific to this page -->
</main>
<footer>
<!-- contact, privacy, ©: repeated on every page -->
</footer>
</body>mainis a block element with no special styles: the page looks the same with it as without it.- It creates the main region (main content), which screen readers let users reach directly with a shortcut. It is probably the most-used shortcut of all: "take me to what matters".
- Search engines and browser reading modes use it as a clue to where the valuable content is.
One Visible per Page
The fundamental rule is: there can only be one visible main in each document. It makes sense: if there were two, which would be the main one?
| Rule | Detail |
|---|---|
A single visible main |
There can be others in the code if they are hidden with the hidden attribute (for example, in applications that show one "view" or another), but only one visible at a time |
It can't be inside article, aside, header, footer or nav |
The main content can't be part of a complement, a header or a footer |
Its natural place is as a child of the body |
It can also be inside a div (for example, a layout container) |
| It isn't compulsory, but it is highly recommended | Every page with content should have one |
<!-- Incorrect: main inside an article, and two visible main elements -->
<article>
<main>…</main>
</article>
<main>…</main>
<!-- Correct: a single main, child of the body -->
<main>
<article>…</article>
</main>What Goes Inside main and What Doesn't
The test is simple: is this content specific to this page, or is it repeated on every page?
| Content | Inside main? |
Reason |
|---|---|---|
The page's h1 |
Yes | It is the title of the main content |
The page's section and article elements |
Yes | They are its own content |
An aside related to the content of the page (the offer on the home page, the newsletter on the news page) |
Yes | It complements the content of this page |
| A search box or a form specific to the page | Yes | It is part of the content |
| The header with the logo and the main menu | No | It is repeated across the whole site |
| The footer with contact details, privacy and copyright | No | It is repeated across the whole site |
An aside repeated across the whole site (for example, a global sidebar) |
No | It isn't specific to the page |
graph TD
BODY["body"] --> H["header<br>(repeated)"]
BODY --> M["main<br>(specific to the page)"]
BODY --> F["footer<br>(repeated)"]
M --> H1["h1"]
M --> S["section / article"]
M --> A["page aside"]
A practical hint: if something doesn't change when you move to another page, it probably doesn't go in
main.
A Preview: the "Skip to Content" Link
A person who navigates using only the keyboard moves from link to link with the Tab key. At The Blue Cup, before reaching the content they would have to go through the logo and the six menu links every time. That is why many sites include, as the first element of the body, a link that jumps straight to the main content:
<body>
<a href="#content" class="skip-link">Skip to content</a>
<header>…</header>
<main id="content">…</main>
</body>- It is a link to an anchor, like the ones you created in Special Links: Anchors, Email, Phone and Downloads.
- The target is the
main, which needs anid. - It is usually hidden visually and only appears when it receives keyboard focus (that is done with CSS).
Don't add it yet: you will implement it in full, with its CSS, in Web Accessibility Basics. What you will do in this lesson is get id="content" ready on the main of each page.
figure and figcaption: Illustrative Content with Its Caption
The figure element represents self-contained content (an image, a diagram, a video, a code fragment…), usually with a caption (figcaption), which the main text refers to but which could be moved elsewhere (to a side panel, to an appendix) without breaking the flow of reading. It is the same as the "figures" in a textbook: "Figure 3: The front of the premises".
<figure>
<img src="img/storefront.jpg" alt="The Blue Cup's storefront with its blue awning and a terrace with four tables" width="800" height="600">
<figcaption>Our premises at 12 Example Street, open since 2026.</figcaption>
</figure>Let's analyse it:
figurewraps the image and its caption and turns them into a unit. A screen reader announces "figure" and associates the caption with the image.figcaptionis the figure's caption. There can only be one perfigure, and it must be the first or last child (above or below the content).- The image keeps its
alt: thefigcaptiondoesn't replace it. - By default, the browser applies a margin on both sides of a
figure(which is why it appears slightly indented). You will be able to adjust it with CSS in Module 8.
alt Versus figcaption
They are two different texts with different jobs:
alt |
figcaption |
|
|---|---|---|
| Who sees it? | Only people who don't see the image (screen reader, image that doesn't load) | Everyone |
| What does it say? | What is in the image, so as to replace it | Additional information: context, author, date, place |
| Example | "The Blue Cup's storefront with its blue awning and a terrace with four tables" | "Our premises at 12 Example Street, open since 2026." |
Don't copy the same text into both: a screen reader user would hear it twice. If the caption already describes the image completely, the alt can be shorter, but it must never be missing.
What Can Go in a figure
Although it is most often used with images, figure works for any illustrative content:
Several Images with a Shared Caption
<figure>
<img src="img/dough-before.webp" alt="Freshly kneaded bread dough in a bowl" width="300" height="300">
<img src="img/dough-after.webp" alt="The same dough, twice the size after proving" width="300" height="300">
<figcaption>The dough before and after 12 hours of fermentation.</figcaption>
</figure>A Video
<figure>
<video controls width="640" height="360" poster="img/intro-poster.jpg">
<!-- sources and track, as in Embedding Videos -->
</video>
<figcaption>A day in The Blue Cup's bakery (1 minute, with subtitles).</figcaption>
</figure>A Code Fragment
<figure>
<pre><code><nav aria-label="Main menu">…</nav></code></pre>
<figcaption>Example 1: The Blue Cup's main menu.</figcaption>
</figure>(Remember from Block Quotes and Preformatted Text that < and > are written as < and > inside pre.)
A Table
A table already has its own title, caption, which you learnt about in Accessible Tables: caption, scope and headers. That is why you don't normally need figure for a table. If for some reason you wrap it in a figure (for example, to give it a caption with the source of the data), use figcaption or caption, but not both with the same text.
A Quotation with Its Attribution
This is a very practical use. In Block Quotes and Preformatted Text you learnt that the attribution (who said it) does not go inside the blockquote, because it isn't part of what is being quoted. But you left it in a separate paragraph, with nothing to link it to the quotation. figure solves that relationship:
<figure>
<blockquote cite="https://reviews.example/the-blue-cup">
<p>The best croissant in the neighbourhood, and the coffee is always spot on.</p>
</blockquote>
<figcaption>Marta G., regular customer</figcaption>
</figure>- The
blockquotecontains only what is quoted. - The
figcaptioncontains the attribution. - The
figurebrings them together: it is now clear, to machines as well, that this attribution belongs to that quotation.
| Content | Main element | With figure? |
|---|---|---|
| Photo with a caption | img |
Yes |
| Several photos with a shared caption | img (several) |
Yes |
| Video with a description | video |
Yes, if it has a caption |
| Numbered or explained code fragment | pre + code |
Yes |
| Table | table with caption |
Usually not |
| Quotation with its author | blockquote |
Yes |
figure Versus a Plain img
Not every image should go in a figure. The key question is: is the image a self-contained illustration, with or without a caption, that could be moved without breaking the text?
| Image | figure? |
Reason |
|---|---|---|
| Photo of the storefront in the gallery, with a caption | Yes | A self-contained illustration with a caption |
| Product photos in the gallery, with their names | Yes | Each one is an illustration with a caption |
| The linked logo in the header | No | It is a navigation link, not an illustration |
The decorative divider bean-divider.svg |
No | It is decoration (alt=""): it has nothing to illustrate |
| A small icon within a sentence | No | It is part of the text |
| An image that is an essential part of a step-by-step guide and can't be moved | Usually not | It isn't self-contained: the text depends on its position |
And one nuance: a figure doesn't have to have a figcaption. You can use it without a caption if the content is a self-contained illustration; but in practice, if there is no caption, a plain img is usually enough.
Project: main on Every Page, the Gallery and the Reviews
main on Every Page
main on Every PageOn every page of the site (the six in the menu and privacy.html), wrap everything between the header and the footer in a main with id="content". The skeleton of index.html now looks like this:
<body>
<header>
<p class="logo"><!-- linked logo --></p>
<nav aria-label="Main menu"><!-- ul.menu --></nav>
</header>
<main id="content">
<section class="welcome"><!-- h1 + introduction --></section>
<section id="bakery"><!-- … --></section>
<aside class="featured" id="offer"><!-- … --></aside>
<section id="book"><!-- … --></section>
<section id="opening-hours"><!-- … --></section>
<section id="reviews"><!-- … --></section>
</main>
<footer><!-- contact, short opening hours, privacy, © --></footer>
</body>- The
h1of each page stays inside themain: it is the title of the main content. - In
news.html, the search box, thearticleelements and the newsletterasidego inside themain: they are all specific to that page. - In
bookings.htmlandcontact.html, the forms go inside themain. id="content"is ready for the "Skip to content" link.
gallery.html: Photos with Captions
gallery.html: Photos with CaptionsIn the "Our premises" block, wrap the storefront photo in a figure with its caption (keep the alt you already had if you prefer it to the one in this example):
<section id="premises">
<h2>Our premises</h2>
<figure>
<img src="img/storefront.jpg" alt="The Blue Cup's storefront with its blue awning and a terrace with four tables" width="800" height="600">
<figcaption>Our premises at 12 Example Street, Fictional Town.</figcaption>
</figure>
</section>In "From our bakery to your table", each item in the ul.product-gallery list now contains a figure with the product's name and price as its caption:
<section id="products">
<h2>From our bakery to your table</h2>
<ul class="product-gallery">
<li>
<figure>
<img src="img/croissant.webp" alt="Golden, flaky croissant on a white plate" width="400" height="400">
<figcaption>Butter croissant · €2.40</figcaption>
</figure>
</li>
<li>
<figure>
<img src="img/lemon-cake.webp" alt="Slice of lemon sponge cake with white icing" width="400" height="400">
<figcaption>Lemon sponge cake · €2.20</figcaption>
</figure>
</li>
<li>
<figure>
<img src="img/sourdough.webp" alt="Sourdough loaf with a golden-brown crust" width="400" height="400">
<figcaption>Sourdough bread · €3.00</figcaption>
</figure>
</li>
</ul>
</section>- The list stays: it is still a set of products, and a screen reader will announce "list, 3 items".
- Each
licontains afigure: the list says "there are three", the figure says "this image with this caption". - The
altdescribes the photo; thefigcaptiongives the name and price, which can't be seen in the image. They don't repeat each other. - The prices match the table in
menu.html. If you change a price, remember to update it in both places. - The decorative divider does not become a
figure.
index.html: Reviews as Attributed Quotations
index.html: Reviews as Attributed QuotationsIn the #reviews section, each div.review becomes a figure.review, and the p.author paragraph becomes its figcaption:
<section id="reviews">
<h2>What our customers say</h2>
<figure class="review">
<blockquote cite="https://reviews.example/the-blue-cup">
<p>The best croissant in the neighbourhood, and the coffee is always spot on. I don't have breakfast anywhere else now.</p>
</blockquote>
<figcaption>— Marta G., regular customer</figcaption>
</figure>
<figure class="review">
<blockquote>
<p>I did the sourdough bread-making workshop and I'm definitely coming back. They explain everything very patiently.</p>
</blockquote>
<figcaption>— Andrew P., workshop participant</figcaption>
</figure>
<!-- links to the "Neighbourhood Cafés 2026" guide and to the reviews website, unchanged -->
</section>- The
reviewclass is kept (it will be used to style the reviews as cards) and theauthorclass is no longer needed: the CSS will be able to selectfigcaption. - What was announced in Block and Inline Elements: div and span has come true: the
div.reviewwas a stopgap until you metfigure. - Why
figureand notarticle? Both options can be defended. A long review, with a title, a rating and a date, would be anarticle. For a short quotation with its author,figure+blockquote+figcaptionis the most precise structure.
- Checking It
- Open all the pages with Live Server. The gallery and the reviews now appear slightly indented: that is the default margin of
figure. You will adjust it in Module 8. - In the DevTools accessibility tree, check that each page has exactly one
mainregion. - Type
index.html#contentinto the address bar: the page will jump to the start of the main content, just after the menu.
Common Mistakes and Tips
- Putting the menu or the footer inside
main. Whatever is repeated on every page goes outside. - Two visible
mainelements on the same page. Only one. - Putting
maininside anarticle,aside,header,footerornav. It isn't allowed. - Using
figcaptionoutside afigureor placing it in the middle of the content: it must be the first or last child of itsfigure. - Duplicating the
alttext in thefigcaption. Each has its own job. - Removing the
altbecause there is already afigcaption. Thealtis still required. - Putting the attribution inside the
blockquote. It goes in thefigcaption. - Wrapping every image in a
figure. Logos, icons and ornaments aren't figures. - Tip: a good caption answers what the image can't tell on its own: who, where, when, how much it costs.
Exercises
Exercise 1. In gallery.html, wrap the introductory video in a figure with a caption stating what it shows, its approximate length (1 minute) and that it has subtitles. What do you do with the descriptive paragraph that was already above the video?
Exercise 2. This code has four mistakes. Find them and correct them:
<body>
<main>
<header>
<nav><!-- menu --></nav>
</header>
<h1>Gallery</h1>
<figure>
<figcaption>Cup of cappuccino</figcaption>
<img src="img/cappuccino.webp" width="400" height="400">
<figcaption>Cappuccino · €2.20</figcaption>
</figure>
</main>
<main>
<p>More photos coming soon.</p>
</main>
</body>Exercise 3. In news.html, the workshop news item includes the head baker's quotation with q inside a paragraph. Add a featured block quotation to that news item: "Sourdough won't be rushed", attributed to "Carmen, head baker at The Blue Cup", using the semantic structure you have learnt. Why does it make no sense to use the blockquote's cite attribute here?
Solutions
Solution 1.
<section id="video">
<h2>Get to know The Blue Cup on video</h2>
<figure>
<video controls width="640" height="360" poster="img/intro-poster.jpg">
<!-- webm source, mp4 source and subtitle track, unchanged -->
</video>
<figcaption>A day at The Blue Cup, from the bakery to the counter (1 minute, with English subtitles).</figcaption>
</figure>
</section>The descriptive paragraph before the video can be kept if it provides different information (for example, an invitation to watch it), or turned into the figcaption if it said the same thing. What you must avoid is repeating the same information in the paragraph and in the caption.
Solution 2.
- The
headerwith the menu is inside themain: it must go outside, before themain. - There are two
figcaptionelements in the samefigure: only one is allowed. Keep the one that provides information (name and price). - The image has no
alt. - There are two visible
mainelements. The "More photos coming soon" notice is part of the gallery's content: it goes inside the singlemain.
<body>
<header>
<nav><!-- menu --></nav>
</header>
<main>
<h1>Gallery</h1>
<figure>
<img src="img/cappuccino.webp" alt="Cup of cappuccino with leaf-shaped foam" width="400" height="400">
<figcaption>Cappuccino · €2.20</figcaption>
</figure>
<p>More photos coming soon.</p>
</main>
</body>Solution 3. Inside the workshop article, after the paragraph with the short quotation (or instead of it, if you don't want to repeat the sentence):
<figure>
<blockquote>
<p>Sourdough won't be rushed.</p>
</blockquote>
<figcaption>Carmen, head baker at The Blue Cup</figcaption>
</figure>The blockquote's cite attribute is used to give the URL of the source of the quotation. Here the sentence was said in the interview recorded by the café itself; there is no external page it comes from. If you wanted to, you could point to the transcript on the same page (cite="#bread-workshop"), but it isn't necessary. Remember that the cite attribute isn't displayed; the visible attribution is the one in the figcaption.
Conclusion
In this lesson you have completed the skeleton of the pages: main marks the main content, the content specific to each page; there can only be one visible, never inside a header, a footer, an article or a complement, and it creates the region that screen reader and keyboard users jump to in order to get to what matters (with id="content" ready for the "Skip to content" link in Module 10). You have also mastered figure and figcaption, the pair that links illustrative content (images, videos, code, tables or quotations) with its caption, and you can tell the alt, which replaces the image, from the figcaption, which complements it, and know when a plain img is enough. Every page of The Blue Cup now follows the header – main – footer outline, the gallery shows products with their names and prices, and the reviews are attributed quotations. There are still some pieces of data that machines don't understand yet (the dates of the news items, the address in the footer) and content it would be useful to be able to collapse or display in a dialog box. You will solve this in the last lesson of the module, Other Semantic Elements: time, address, details and dialog.
HTML Course
Module 1: Introduction to HTML
- What Is HTML?
- Setting Up Your Work Environment
- Basic Structure of an HTML Document
- Tags, Elements and Attributes
- Creating Your First HTML Page
- File Organisation and Paths
Module 2: Text Formatting in HTML
- Headings and Paragraphs
- Text Formatting Tags
- Lists: Ordered, Unordered and Description Lists
- Block Quotes and Preformatted Text
- Block and Inline Elements: div and span
Module 3: Links and Media in HTML
- Creating Hyperlinks
- Special Links: Anchors, Email, Phone and Downloads
- Adding Images
- Embedding Videos
- Using the Audio Element
Module 4: Tables in HTML
- Basic Table Structure
- Table Head, Body and Foot
- Merging Cells: colspan and rowspan
- Accessible Tables: caption, scope and headers
- Styling Tables
Module 5: Forms in HTML
- Creating a Basic Form
- Form Elements: input, textarea and select
- HTML5 Input Types
- Labels and Grouping: label, fieldset, legend and datalist
- Form Attributes and Validation
- Submitting Forms
Module 6: HTML5 Semantic Elements
- Introduction to Semantic HTML
- header, nav and footer
- article, section and aside
- main and figure
- Other Semantic Elements: time, address, details and dialog
Module 7: Advanced HTML Techniques
- HTML Entities
- Using iframes
- Data Attributes
- Metadata: meta, SEO and Open Graph
- Microdata and Structured Data
- Graphics in HTML: SVG and canvas
Module 8: Integrating HTML and CSS
- Linking CSS to HTML
- Inline, Internal and External CSS
- Basic CSS Selectors
- The Box Model
- Styling HTML Elements
- Introduction to Layout with Flexbox and Grid
Module 9: Responsive Web Design
Module 10: Best Practices and Accessibility
- HTML Best Practices
- Validating HTML Code
- Web Accessibility Basics
- Using ARIA Roles and Attributes
- Accessibility Testing
- Performance and Resource Loading
