When should I use article, section, or a generic container?
Quick answer
Use <article> for related content that can make sense on its own, such as a self-contained post. Use <section> to group content around a theme or function, and introduce it with a heading. Use a generic <div> when you need a wrapper for grouping but the content does not have either of those meanings. Choose based on purpose, not appearance. [S1]
The question, the details, the next step.
A practical checklist
Describe what the content chunk means before choosing its HTML element.
Use
<article>when the content is related and makes sense as a piece on its own.Use
<section>for a themed or functional group, and introduce it with a heading.Use
<div>when grouping is needed but no more specific semantic meaning fits.Reconsider wrappers chosen for appearance alone; remove them if they have no clear purpose.
A few more useful answers
Can a page contain more than one `<section>`?
Yes, when the page has multiple distinct themed or functional groups. Choose each section because of what its content represents, not simply to divide the layout.
Is `<div>` a bad choice?
No. A generic container is appropriate when grouping is needed and no suitable semantic element expresses the content’s meaning. [S1]
Does a visible card automatically count as an `<article>`?
No. Appearance alone does not establish that it is a self-contained piece. Decide from the content’s purpose.
Sources
References used for this guide.
- [S1] Structuring documents: Semantic structural elements developer.mozilla.org · Checked
