In HTML, how do you decide between <article>, <section>, and <div> for a block of page content?
answer
- standalone, thematic, or nothing at all
- the heading test
- syndication test for one of them
- div is not a failure state
- unnamed one is silently generic
basics
~20 sUse <article> when the block would still make sense on its own elsewhere, <section> for a thematic part of a document that has its own heading, and <div> when the grouping exists only for styling or scripting.
solid answer
~50 sI ask two questions. First: would this block still make sense pulled out of the page — in a feed, a reader, an email? If yes it is an `<article>`: a blog post, a product card, a comment, a forum reply. Second: is this a distinct thematic chunk of a larger document that I would naturally give a heading to? Then it is a `<section>` — the spec is explicit that a section normally has a heading, and if you cannot think of one, that is the signal it is not a section. Everything else is a `<div>`: a flex wrapper, a scroll container, a hook for a class or a script. `<div>` is not a failure state, it is the correct element when there is no semantics to express. The common mistake is treating `<section>` as a prettier `<div>` and wrapping every layout box in one, which adds no meaning and can flood a screen reader's landmark list.
code
html · 14 lines<section aria-labelledby="reviews-h">
<h2 id="reviews-h">Customer reviews</h2>
<div class="review-list">
<article>
<h3>Worth it</h3>
<p>Six months in and no complaints.</p>
</article>
<article>
<h3>Mixed feelings</h3>
<p>Great screen, poor battery.</p>
</article>
</div>
</section>go deeper
Learn the one-line rule and one example each: article for a blog post or product card, section for a titled part of a page, div for a layout wrapper. Say it without hedging.
Explain the two tests — standalone/syndicatable for article, has-a-heading for section — and be able to justify why a specific div in real markup should stay a div.
Bring in the accessibility-tree consequence: an unnamed section is generic, so <section> sprinkled everywhere buys nothing, while a wrongly applied <article> actively misleads. Show how you would audit an existing page.
Frame it as a convention problem: agree what a component library's shell element is, so that a card component does not decide unilaterally to be an <article> in contexts where it is a layout fragment.
## The decision, in order The three elements are not interchangeable and they are not a quality ladder. They answer different questions. **Would the content stand alone?** If you could syndicate this block — put it in an RSS feed, a "related posts" widget, a reader view, another page — and it would still be coherent, it is an `<article>`. The spec's wording is "a complete, or self-contained, composition… intended to be independently distributable or reusable". Blog posts, news stories, product cards, user comments, forum posts, and interactive widgets all qualify. Note that self-contained does not mean top-level: a comment is an `<article>` nested inside the post's `<article>`, and that nesting is exactly how the spec expects comments to be marked up. **Is it a thematic part of something larger, with a heading?** Then it is a `<section>`. The heading test is the practical one: HTML says a `<section>` should normally have a heading, so if you cannot write a sensible heading for the block, it is probably not a section. "Pricing", "FAQ", "Specifications", "Chapter 3" are sections. A row of three cards is not a section just because it is visually distinct. **Otherwise, `<div>`.** A wrapper that exists to hold a grid, a border radius, a scroll region, a transform, or a JavaScript hook is a `<div>`, and reaching for a semantic element instead is a downgrade, not an upgrade — you are asserting meaning that is not there. ## What each one actually does ```html <main> <h1>Notebooks</h1> <section aria-labelledby="featured-h"> <h2 id="featured-h">Featured</h2> <div class="grid"> <!-- pure layout --> <article> <h3>Model 14</h3> <p>Lightweight and fast.</p> </article> <article> <h3>Model 16</h3> <p>More screen, more ports.</p> </article> </div> </section> </main> ``` Each product card is independently distributable, so it is an `<article>`. "Featured" is a thematic part of the page with a heading, so it is a `<section>`. The grid wrapper carries no meaning at all, so it is a `<div>`. In the accessibility tree, `<article>` maps to the `article` role; `<section>` maps to `region` **only when it has an accessible name** (here, via `aria-labelledby` pointing at its heading) and to generic otherwise; `<div>` maps to generic always. That last detail explains why sprinkling `<section>` everywhere is often a no-op — an unnamed section is, to assistive technology, exactly the `<div>` you were trying to avoid. ## Where candidates go wrong The most common failure is the belief that `<div>` is bad markup and every `<div>` should be upgraded. That produces `<section class="flex-row">` and `<article class="card-shell">` on blocks that are neither. Semantics you do not mean are worse than no semantics: a screen-reader user who navigates into an "article" expecting a self-contained composition and finds a layout wrapper has been misled. The second failure is the opposite reflex — treating `<article>` as "only for blog posts". Anything self-contained qualifies, including a widget or a card, and a page can contain many articles. The third is assuming these elements do something visual or something for search ranking. They do not change rendering (beyond the user-agent stylesheet's block display), and the value is the meaning carried into the accessibility tree and into any tool that parses structure — not a ranking lever. ## A quick heuristic to say out loud "Self-contained and reusable → `article`. Thematic chunk that deserves a heading → `section`. Nothing to say about it → `div`." Then be ready to defend a real example on your own CV site or the interviewer's page. Interviewers ask this specific question constantly because it is where a candidate either recites a list of HTML5 tags or demonstrates that they have actually made the choice on real markup.
- Can an <article> contain other <article> elements?Yes, and the spec expects it. A blog post is an `<article>`, and each comment on it is an `<article>` nested inside — each comment is itself a self-contained composition. The same shape works for a forum thread with replies. Nesting does not weaken the outer article's meaning; it just says the inner content is independently distributable too.
- Is <div> ever the better choice than a semantic element?Whenever the grouping carries no meaning — a flex or grid wrapper, a scroll container, a positioning context, a hook for a class or a script. Using `<section>` there asserts a thematic division that does not exist, and using `<article>` asserts self-containment that is false. Meaningless markup is honest; wrong markup misleads assistive technology.
- A designer's page has six visually distinct bands. Should each be a <section>?Only the ones you can name with a real heading. Bands like "Pricing" or "Testimonials" are genuine thematic divisions. A hero image, a spacer band or a decorative strip is not — it is a `<div>`. Wrapping all six in `<section>` and naming them all produces a landmark list nobody wants to navigate.
saying these in an interview costs you the question
- Believing <div> is always bad markup to be replaced
- Using <section> as a styling wrapper with no heading
- Thinking <article> only means blog posts or news
- Claiming these elements improve search ranking directly
- Assuming <section> is always announced as a region