Recent chats
ASKGEEZ Q&A GUIDETechnology & devices

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]

LET’S WORK THROUGH IT

The question, the details, the next step.

Question

I’m adding structure to a page. What’s the quickest way to choose between <article>, <section>, and <div>?

Geez

Ask what the content itself represents—not what shape or visual style you want.

  1. Could this content make sense as a distinct, self-contained piece? Consider <article>.
  2. Is it a themed or functional part of a larger page? Consider <section>, usually with a heading that introduces the group.
  3. Is it simply a wrapper for grouping content, without a more specific meaning? Use <div>.

These distinctions follow MDN’s descriptions of the elements. [S1] A layout that looks like a card, box, or column does not, by itself, tell you which element to choose.

Follow-up question

Can you show how that works for a page with a post, a group of related links, and a wrapper used for layout?

Geez

Assume the page contains a complete post, a heading followed by links on one topic, and an outer wrapper used only to group page content. One possible structure is:

<div class="page-layout">
  <article>
    <h2>Planning a small garden</h2>
    <p>A self-contained example post goes here.</p>
  </article>

  <section>
    <h2>More about garden planning</h2>
    <ul>
      <li><a href="#example">Example related link</a></li>
    </ul>
  </section>
</div>

Here, the post is treated as its own piece, the links form a themed group introduced by a heading, and the outer wrapper has no special content meaning. These are illustrative choices, not rules about how every page must be built. The definitions support the distinctions, but do not establish that this exact structure is right for every design. [S1]

Follow-up question

What if I have several chunks of content, but none has a heading? Should I still use <section> to make the page more semantic?

Geez

Don’t add <section> just to make the markup seem more meaningful. First ask whether the chunk has a distinct theme or function within the page. MDN recommends introducing sections with a heading, so consider whether a heading would clearly introduce that group. [S1]

If the chunk is instead just a wrapper for layout or grouping, and neither <article> nor another meaningful element fits, use <div>. If the content is a standalone piece, <article> may fit. Select an element for the content’s purpose rather than adding semantic labels without a clear reason.

Follow-up question

Could you give me a decision tree I can reuse while reviewing a page?

Geez

Use this short decision tree for each chunk:

  1. Is it related content that makes sense on its own? If yes, consider <article>.
  2. If not, does it group a themed or functional part of the page? If yes, consider <section> and introduce the group with a heading.
  3. If neither meaning fits, do you still need to group elements? If yes, use <div>; if no, you may not need a wrapper at all.
  4. Review the purpose: Can you explain why you chose that element without referring only to its appearance? If not, reconsider.

The first two questions follow MDN’s descriptions of <article> and <section>; its guidance reserves a generic <div> for grouping when no suitable semantic element fits. [S1] This is a practical review aid, not a substitute for judging the actual content.

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.

  1. [S1] Structuring documents: Semantic structural elements
    developer.mozilla.org · Checked

YOUR QUESTION. YOUR DETAILS.

Let’s work through your situation.

Get a tailored answer or help with your next task. Starts at $1, with a quote before you pay.

Ask your own question
← Back to Geez at Work