Article & Section
<article> and <section> are the two most misused semantic elements. They're both block containers, both accept headings, and both can nest inside each other — yet they have distinct, specific meanings. This lesson pins down exactly when to use each, how to nest them correctly, and introduces <figure> and <figcaption> for self-contained media content.
article — Self-Contained & Redistributable
The test for <article>: could this content be pulled out and published somewhere else — a feed reader, a social card, a syndication partner — and still make complete sense on its own? If yes, use <article>. Blog posts, news articles, forum posts, product cards, comment items, and widget components all qualify.
<div class="post"> <div class="post-head"> <h2>How CSS Grid Works</h2> <div class="meta">June 2025</div> </div> <div class="post-body"> <p>Content...</p> </div> </div>
<article> <header> <h2>How CSS Grid Works</h2> <time datetime="2025-06-01"> June 2025 </time> </header> <p>Content...</p> </article>
A comment section is a classic pattern that trips people up — each individual comment is an <article> nested inside a parent <article> (the post itself):
<article> <!-- The main post --> <h1>My Blog Post</h1> <p>Post content...</p> <section> <!-- Comments section --> <h2>Comments (3)</h2> <article> <!-- Individual comment --> <header> <strong>Alice</strong> <time datetime="2025-06-15T09:00">June 15</time> </header> <p>Great post!</p> </article> <article> <!-- Another comment --> <header> <strong>Bob</strong> <time datetime="2025-06-16T14:30">June 16</time> </header> <p>Very helpful, thanks!</p> </article> </section> </article>
section — Thematic Grouping
<section> groups content that is thematically related but isn't self-contained enough to syndicate on its own. The rule: every <section> must have a heading. If you'd feel awkward giving it an <h2>, it probably shouldn't be a <section> — use a <div> instead.
| Use section for… | Use div for… |
|---|---|
| A "Features" section on a landing page | A flex wrapper around cards |
| A "Reviews" section on a product page | A centering container |
| Chapters of a long article | A JS hook container (id="modal-root") |
| The "Comments" block at the end of a post | A visually styled box with no distinct content meaning |
<main> <section id="features"> <h2>Features</h2> <div class="cards-grid"> <!-- div — just layout --> <article class="feature-card">...</article> </div> </section> <section id="pricing"> <h2>Pricing</h2> <p>Plans for every team size...</p> </section> <section id="testimonials"> <h2>What customers say</h2> <!-- each review is self-contained → article --> <article>...</article> <article>...</article> </section> </main>
<section> is one of the most over-used elements. A background-colored stripe on a landing page that just holds a heading and some cards is tempting to wrap in <section>, but if it has no special heading hierarchy meaning, a <div> is correct. Semantic elements carry meaning — don't use them just because they sound more "professional."article vs section — The Decision Tree
These two questions decide which element to use:
One key nuance: <article> and <section> can each contain the other. A blog post (<article>) can have <section> chapters inside it. A comments <section> can contain individual comment <article> elements.
<section> and <article> starts a new heading context. The first heading inside should be the most important one in that context (<h1> inside an <article> doesn't conflict with the page's <h1>). In practice, most developers start sections with <h2> and subsections with <h3> to stay safe across all assistive technologies.figure & figcaption — Captioned Media
<figure> wraps any self-contained content that is referenced from the main flow but could be moved without breaking reading continuity — images, code listings, charts, diagrams, audio, and video. <figcaption> provides its caption.
<!-- Image with caption --> <figure> <img src="grid-diagram.png" alt="CSS Grid with 3 columns labeled A, B, and C"> <figcaption> Figure 1. A basic three-column CSS Grid layout. </figcaption> </figure> <!-- Code listing with caption --> <figure> <pre><code> .container { display: grid; } </code></pre> <figcaption>Listing 1. Minimal grid container.</figcaption> </figure> <!-- figcaption can go before OR after the content --> <figure> <figcaption>Before the image is valid too</figcaption> <img src="photo.jpg" alt="..."> </figure>
alt is a text replacement for the image when it cannot be displayed. <figcaption> is a visible description visible to everyone. An image of a chart might have alt="Bar chart showing 3 columns" (describes what the image is) and a <figcaption> of "Figure 2. Monthly visitors by channel" (gives context for why it's shown here). Both should be present when the image carries information.Up next: Module 8 — Media & Embeds. Audio, video, iframes, and SVG.
The page should contain:
- A <main> with two sections: "Latest News" and "Opinion"
- "Latest News" section: 3 article elements, each with a header (h2 title + time element), a paragraph summary, a figure with an img+figcaption, and a footer with "Read more" link
- "Opinion" section: 2 article elements structured the same way
- Each article's figure should use a placeholder image (e.g., via.placeholder.com or a local image) with a meaningful alt text and a descriptive figcaption
- One of the "Latest News" articles should have a nested section inside it titled "Key takeaways" with a list of 3 bullet points
- A sidebar aside with "Editor's Picks" (list of 4 links)
Bonus: add CSS to lay out main as a 2-column grid (articles column + aside column) and style the figure images as rounded thumbnails.
Show hints
- Feature cards (article inside section) are very common; this challenge mirrors real news site structure
- <figure> inside <article> is perfectly valid nesting
- The "Key takeaways" subsection inside an article uses <section> with <h3>Key takeaways</h3>
- Grid layout: main { display: grid; grid-template-columns: 2fr 1fr; gap: 2rem; }
- figcaption text color is typically muted — try color: #888 and font-size: 0.85rem