Sub topic 5
section versus article
This chapter assumes you know basic HTML syntax, can open your browser's developer tools, and have read the earlier chapters on landmarks and headings. It covers how section and article differ, when each is correct, and when neither is.
Two elements, two different tests
Both elements are sectioning content. Each marks a chunk of the page that has its own heading. They answer different questions.
articleasks: could this chunk be lifted out and still make sense on its own? Think of a syndicated feed, a printed copy, or a share card.sectionasks: is this chunk one theme within a larger whole, and does it have a heading that names the theme?
An article stands alone. A section belongs to its parent. If a chunk fails both tests, you probably want a div.
| Question | article | section |
|---|---|---|
| Makes sense out of context? | Yes | Not necessarily |
| Needs a heading? | Strongly recommended | Yes, or an accessible name |
| Typical content | Blog post, news story, comment, product card, forum post | Chapter, tab panel content, "Features" block on a landing page |
| Default accessibility role | `article` | `generic`, or `region` if it has an accessible name |
| Can nest in itself? | Yes (comments inside a post) | Yes (subsections) |
article: self-contained content
Use article for content that is complete in itself and could be reused elsewhere. The HTML specification lists examples such as a forum post, a magazine or newspaper article, a blog entry, a product card, a user-submitted comment, and an interactive widget.
<article>
<header>
<h2>Why semantics matter</h2>
<p>Published <time datetime="2026-11-30">30 November 2026</time> by Sam Lee.</p>
</header>
<p>Use <strong>meaningful</strong> elements, not just ones that <em>look</em> right.</p>
<footer>
<p>Filed under: HTML, accessibility</p>
</footer>
</article>The header and footer inside an article describe that article. They are not page-level banner or contentinfo landmarks. Browsers only expose those roles when header and footer are scoped to the body.
Nested articles
Articles can nest when the inner one is related to the outer one. The standard case is a post with reader comments. Each comment is independently meaningful, and each has its own author and date.
<article>
<h2>Release notes for version 4</h2>
<p>The new editor ships today.</p>
<section aria-labelledby="comments-heading">
<h3 id="comments-heading">Comments</h3>
<article>
<h4>Re: Release notes</h4>
<p>Posted by <strong>Ana</strong> on <time datetime="2026-11-30">30 November</time></p>
<p>The keyboard shortcuts are a big improvement.</p>
</article>
<article>
<h4>Re: Release notes</h4>
<p>Posted by <strong>Raj</strong> on <time datetime="2026-12-01">1 December</time></p>
<p>Does this work with screen readers?</p>
</article>
</section>
</article>Two things to notice. The comments sit inside a section that groups them under the heading "Comments". The section is a theme within the post, and each comment is a standalone unit. The heading levels also follow the document's actual depth, which the next section explains.
section: a themed group with a heading
Use section when you are splitting one piece of content into named parts. A guide with "Installation", "Configuration" and "Troubleshooting" parts is the usual example. Each part has a heading, and none of them makes full sense without the guide around it.
<article>
<h1>Getting started with Widgets</h1>
<section>
<h2>Installation</h2>
<p>Run the installer and restart your shell.</p>
</section>
<section>
<h2>Configuration</h2>
<p>Edit the config file in your home directory.</p>
</section>
</article>A section with no heading is a warning sign. If you cannot say what theme the group has, you are using it as a styling wrapper, and a div says that more honestly.
Headings do not reset inside sections
The HTML specification once described an outline algorithm. Under it, an h1 inside every section would be treated as a lower level automatically. No browser or screen reader ever implemented it, and the specification has since removed it. The level of a heading is the number in its tag: h2 is level 2 wherever it appears.
So pick the heading level from the document's real hierarchy, and do not rely on nesting to adjust it. In the comments example above, the page title is the h1 elsewhere on the page. The post is h2, "Comments" is h3, and each comment title is h4.
How they appear in the accessibility tree
The two elements differ in what they announce to assistive technology.
articlehas the rolearticle. Some screen readers let users jump between articles, and some announce when you enter or leave one.sectionmaps togenericby default, so it adds nothing to navigation. It becomes aregionlandmark only if it has an accessible name, fromaria-labelledbyoraria-label.
<section aria-labelledby="pricing-heading">
<h2 id="pricing-heading">Pricing</h2>
<p>Plans start at $9 per month.</p>
</section>This section is now a named region landmark called "Pricing", and a screen reader user can jump to it. Name a section only when it is important enough to be a navigation target. If you turn every section into a landmark, the landmark list becomes noise and stops helping users find anything.
Combining them
Both elements nest freely in either direction.
- An
articlecan containsectionelements, as in a long guide. - A
sectioncan containarticleelements, as in a "Latest news" block on a home page.
<main>
<h1>Example News</h1>
<section aria-labelledby="latest-heading">
<h2 id="latest-heading">Latest stories</h2>
<article>
<h3><a href="/stories/1">City opens new library</a></h3>
<p>The branch holds 40,000 books.</p>
</article>
<article>
<h3><a href="/stories/2">Transit fares to stay flat</a></h3>
<p>The council voted on Monday.</p>
</article>
</section>
</main>Here the section is the theme ("Latest stories"). Each story is a self-contained article, so it could be syndicated to another site unchanged.
Common mistakes
sectionas a styling wrapper. Wrapping content insectionso you can apply a background gives you no semantic benefit. Usediv.sectionwith no heading. The element is meant to be a named part of the document. Add a heading, or switch todiv.articlefor everything. A sidebar widget with no standalone value is not an article. The test is independence, not importance.- Putting
maininsidearticleorsection.mainis the page's primary content landmark, and there should be one visible per page. It sits at the top level of the body, andarticleandsectiongo inside it. - Using
sectionwherenavorasidefits. If the group is navigation, usenav. If it is tangential content, useaside. Specific elements carry more meaning thansection. - Skipping heading levels to get a visual size. Choose the level for structure and use CSS for size.
Checking your work in devtools
Open the accessibility panel in your browser's developer tools and select an element. Look at its role.
- A
sectionwith no name should showgeneric. A named one showsregion. - An
articleshould showarticle. - A
headerinside anarticleshould not showbanner.
If the role differs from what you expected, check that the name comes from the right source, such as the id referenced by aria-labelledby.
Exercise
A page has a "Customer reviews" block. It contains three reviews, and each has its own author, date, and text. Which elements would you use, and how would you make the block a navigable landmark?
Show answer
Wrap the block in a section with a heading such as <h2 id="reviews-heading">Customer reviews</h2>, and add aria-labelledby="reviews-heading" so it becomes a named region landmark. Mark each review as an article, because each makes sense on its own with its author and date. Use h3 for each review's title if it has one, matching the real heading depth.
Exercise
A developer wraps a page's footer links, a promo banner, and a contact form in three separate section elements, none with a heading, only to apply different background colors. What is wrong, and what should replace them?
Show answer
A section is for a themed group with a heading, and these have none. They exist only for styling. Replace the wrappers with div elements. Then use the specific elements the content calls for: nav for the footer links inside a footer, aside for the promo if it is tangential, and a form with a labelled fieldset or heading for the contact form.