Section, Article & Aside
By the end of this lesson you will be able to look at any block of a page and decide whether it is a <section>, an <article>, an <aside> or a plain <div>. You will also mark up a blog post with comments the way professionals do.
Semantic HTML5 Elements introduced them; here you get a clear test for each.
article: content that stands on its own
An <article> is a complete, self-contained piece of content. Use this test: would it make sense on its own?
Imagine cutting a story out of a newspaper and pasting it into a scrapbook. If it still makes sense alone, it is an article. On the web, that means it could appear by itself in a news feed or another website. Blog posts, news stories, product cards, reviews, comments and a cricket score widget all pass the test.
An article usually starts with a heading. It often has its own <header> with the author and date, and a <footer> with tags, as you saw in Header, Footer, Nav & Main.
section: a themed part of something bigger
A <section> groups content on one theme, and nearly always has a heading. Unlike an article, it only makes sense as part of the whole, like the "Photosynthesis" chapter of a biology textbook.
A good test for a section: would its heading belong in a table of contents? A course page could have sections called "Syllabus", "Fees" and "Batch timings". Each has a natural heading and covers one theme.
A section is not a styling box. For a wrapper that only adds a background or a grid, use <div>. The HTML standard says plainly that section is not a generic container.
Headings inside sections
Every section and article should start with a heading, and the heading levels must follow the nesting. If the page title is an <h1>, the sections under it use <h2>, and parts inside those use <h3>. Do not skip levels.
<!-- Wrong: every section starts again at h1 -->
<h1>HTML course</h1>
<section>
<h1>Syllabus</h1>
<section>
<h1>Week 1</h1>
</section>
</section>
<!-- Right: levels follow the nesting -->
<h1>HTML course</h1>
<section>
<h2>Syllabus</h2>
<section>
<h3>Week 1</h3>
</section>
</section>Old tutorials say every section can use <h1> and the browser will work out the levels. That "outline algorithm" was never built into browsers or screen readers, and it has been removed from the standard. Screen reader users hear exactly the levels you wrote. See Headings & Paragraphs.
A section becomes a region landmark only when it has a name. Do that for a few important sections by pointing aria-labelledby at the heading's id. Most sections do not need it.
Nested articles: comments and reviews
Articles can contain other articles. The HTML standard says an inner article is related to the outer one. The classic case is comments on a blog post: each comment makes sense on its own, and it belongs to that post.
Step 1. Build the post as an article with a header.
Step 2. Add a section titled "Comments" inside the article.
Step 3. Make each comment its own article with the commenter's name and a date.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Monsoon Cycling in Kochi</title>
<style>
body { font-family: system-ui, sans-serif; margin: 16px; max-width: 640px; }
article { border: 1px solid #ccc; border-radius: 6px; padding: 8px 12px; margin: 8px 0; }
article article { background: #f6f6f6; }
h3 { margin: 0; font-size: 1rem; }
</style>
</head>
<body>
<article>
<header>
<h1>Cycling through Kochi in the monsoon</h1>
<p>By Meera, <time datetime="2026-07-14">14 July 2026</time></p>
</header>
<p>Fort Kochi looks different in the rain. Here is how I ride safely.</p>
<section>
<h2>What to carry</h2>
<p>A rain cape, a spare tube and a dry bag for your phone.</p>
</section>
<section>
<h2>Comments (2)</h2>
<article>
<h3>Farhan</h3>
<p><time datetime="2026-07-15">15 July</time>: Great tips. I add mudguards too.</p>
</article>
<article>
<h3>Ananya</h3>
<p><time datetime="2026-07-16">16 July</time>: Which tyres do you use on wet roads?</p>
</article>
</section>
</article>
</body>
</html>You should see the post with two grey comment boxes inside it, and heading levels running 1, 2, 3. Each comment stands alone, and it sits inside the post because it is about the post.
aside: related, but separate
An <aside> holds content that is related to what is around it, but not part of its main flow. Think of the "Did you know?" boxes in a school textbook. Remove them, and the chapter still makes complete sense.
Good uses of aside:
- a glossary box explaining a term
- a pull quote repeated in large text
- "Related posts" or a sidebar of links
- an advertisement or a short author bio
An aside is not for a remark that belongs in your paragraph, even one in brackets.
Where you put an aside changes its meaning. At page level, next to <main>, an aside relates to the whole page and becomes a complementary landmark. Inside an article, it relates only to that article, and it becomes a landmark only if you give it a name with aria-label.
When nothing fits: div
Some boxes have no meaning: a grid wrapper, a background or a JavaScript hook. That is the job of <div>, and using it is not a failure. Layout boxes marked as <section> add false meaning. See Block, Inline, div & span.
Ask these questions in order and stop at the first "yes":
- Would it make sense on its own, for example in a feed? Use
<article>. - Is it extra, related content the page works without? Use
<aside>. - Is it a themed part with a heading that belongs in a table of contents? Use
<section>. - Is it only a box for layout or a script? Use
<div>.
Step 4. Run this course page. It uses all four, with a <div> doing the layout.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Rohtak Coding Club</title>
<style>
body { font-family: system-ui, sans-serif; margin: 16px; }
.layout { display: grid; grid-template-columns: 2fr 1fr; gap: 16px; }
@media (max-width: 600px) { .layout { grid-template-columns: 1fr; } }
aside { background: #fff7e6; padding: 8px 12px; border-left: 4px solid #e44d26; }
.reviews article { border-bottom: 1px solid #ddd; }
</style>
</head>
<body>
<h1>Web basics course</h1>
<div class="layout">
<main>
<section>
<h2>Batch timings</h2>
<p>Weekdays, 6 pm to 8 pm, starting 1 December.</p>
</section>
<section class="reviews">
<h2>Student reviews</h2>
<article>
<h3>Priya, B.Com student</h3>
<p>I built my first page in week one.</p>
</article>
<article>
<h3>Rohan, shop owner</h3>
<p>Now I update my shop's page myself.</p>
</article>
</section>
</main>
<aside>
<h2>What is a browser?</h2>
<p>The app you use to open websites, such as Chrome or Firefox.</p>
</aside>
</div>
</body>
</html>You should see the course content on the left and the glossary on the right; on a narrow panel they stack. The <div class="layout"> exists only for the grid, so it is a div.
Common mistakes
- Using
<section>as a styling wrapper. Use<div>for boxes that only exist for layout. - A section with no heading. Add a heading or switch to
<div>. - Restarting at
<h1>in every section. Follow the nesting: h2, then h3. - Using
<aside>for a sentence that belongs in the paragraph. Asides are for separate, related content. - Using
<section>for blog cards in a listing. Each card stands alone, so it is an article.
Interview questions
1. What is the difference between section and article?
An <article> is self-contained and would make sense on its own, such as a blog post, product card or comment. A <section> is a themed part of a larger whole, usually with a heading, such as "Fees" on a course page. Either can contain the other.
2. When would you nest one article inside another?
When the inner content is self-contained but related to the outer one, such as comments on a blog post or reviews of a product. Each comment stands alone, and nesting shows which post it belongs to.
3. What is aside for, and does its position matter?
It holds content related to its surroundings but separate from the main flow, such as a glossary box, related links or a pull quote. At page level it relates to the whole page and becomes a complementary landmark. Inside an article it relates only to that article.
4. Can every section use an h1?
It is not an error, but it is bad practice. The outline algorithm that would have adjusted the levels was never implemented and was removed from the standard, so each is announced as level 1.
5. When should you use div instead of section?
When the box has no meaning and exists only for layout, styling or a script hook. A section should have a theme and a heading.
Key points
<article>is for content that would make sense on its own.<section>is a themed part of a whole, with a heading that could go in a table of contents.- Heading levels must follow the nesting; the old automatic outline does not exist in browsers.
- Nested articles show related, self-contained content, such as comments inside a post.
<aside>holds related but separate content; at page level it is a complementary landmark.- When no meaning fits,
<div>is the correct choice.
Exercise
Mark up a product page for a cricket bat sold by a shop in Jaipur. It needs: the product as an article with a heading and price; inside it, a "Specifications" section and a "Reviews" section holding two customer reviews; a glossary aside inside the product explaining "English willow"; and a page-level aside with two related products. Use <div> only for layout, and keep heading levels in order.
Show solution
<div class="layout">
<main>
<article>
<h1>Pro English willow bat</h1>
<p>₹1,299</p>
<section>
<h2>Specifications</h2>
<p>Weight 1.1 kg, short handle, English willow blade.</p>
</section>
<aside aria-label="Glossary">
<h2>English willow</h2>
<p>A light, springy wood used for top-quality bats.</p>
</aside>
<section>
<h2>Reviews</h2>
<article>
<h3>Kabir from Pune</h3>
<p>Good balance for net practice.</p>
</article>
<article>
<h3>Isha from Jaipur</h3>
<p>Light enough for my 12-year-old.</p>
</article>
</section>
</article>
</main>
<aside>
<h2>Related products</h2>
<ul>
<li><a href="#">Batting gloves</a></li>
<li><a href="#">Leather ball</a></li>
</ul>
</aside>
</div>Each review is a nested article: it stands alone but is about that bat. The inner aside relates only to the product; the outer one relates to the whole page.
Quick Quiz
1. Which question best tells you to use <article>?
An article is self-contained content that makes sense outside the page.
2. Comments on a blog post are best marked up as:
Nested articles show content that is self-contained but related to the outer article.
3. A <div> wraps the main column and sidebar only to make a CSS grid. Should it be a <section>?
A section needs a theme and a heading; layout-only boxes are divs.
4. Why should headings inside nested sections not all be <h1>?
The automatic outline algorithm was never implemented and has been removed from the standard.
Learn HTML with a mentor
Free lessons get you started. Our Full Stack Web Development training adds real projects and code reviews from working developers.
- Project-based learning
- Mentor code reviews
- Free counselling call
