HTML Sections & Articles
Master semantic HTML structure with section and article elements. Learn to create meaningful, accessible content organization that both users and search engines understand.
What is the difference between section and article in HTML?
<article> is self-contained content that would make sense on its own, such as a blog post, news story, product card or comment. <section> is a thematic grouping within a page or article, normally introduced by a heading. A good test: if you could syndicate it or share it on its own, it's an <article>.
<article>
<h2>Understanding CSS Grid</h2>
<section>
<h3>Defining columns</h3>
<p>…</p>
</section>
<section>
<h3>Placing items</h3>
<p>…</p>
</section>
</article>Try It: Semantic Structure Essentials
Explore how section and article elements create meaningful content structure. See the difference in organization and accessibility.
Code Editor
<article>
<header><h2>Understanding CSS Grid</h2><p>5 min read</p></header>
<section>
<h3>Defining columns</h3>
<p>Use grid-template-columns…</p>
</section>
<section>
<h3>Placing items</h3>
<p>Use grid-column and grid-row…</p>
</section>
<aside>Related: Flexbox</aside>
</article>Preview
Understanding Sections
The section element represents a thematic grouping of content with a heading. It's used to organize content into logical, related sections.
Section Characteristics:
Purpose & Usage:
- Groups thematically related content
- Usually has a heading (h1-h6)
- Creates document outline structure
- Can contain other sections
Common Examples:
- • Introduction sections
- • Chapter or topic divisions
- • Contact information areas
- • Product feature lists
- • Testimonials groupings
Section Best Practices:
<!-- Good: Section with heading -->
<section>
<h2>Our Services</h2>
<p>Description of services...</p>
</section>
<!-- Good: Nested sections -->
<section>
<h2>Products</h2>
<section>
<h3>Laptops</h3>
<p>Laptop descriptions...</p>
</section>
<section>
<h3>Phones</h3>
<p>Phone descriptions...</p>
</section>
</section>
<!-- Avoid: Section without heading -->
<section>
<p>Random content without theme...</p>
</section>Understanding Articles
The article element represents self-contained, distributable content that could stand alone as a complete piece.
Article Characteristics:
Key Features:
- Self-contained content
- Independently distributable
- Makes sense out of context
- Can have header and footer
Perfect For:
- • Blog posts
- • News articles
- • Product reviews
- • Forum posts
- • Comment threads
- • Tutorial steps
Article Structure Example:
<!-- Complete article structure -->
<article>
<header>
<h2>How to Learn HTML</h2>
<p>Published on <time datetime="2025-03-15">March 15, 2025</time></p>
<p>By <a href="/author/john">John Doe</a></p>
</header>
<p>Learning HTML is the first step in web development...</p>
<p>This tutorial covers the fundamentals...</p>
<footer>
<p>Tags:
<a href="/tag/html">HTML</a>,
<a href="/tag/tutorial">Tutorial</a>
</p>
<p>Share this article on social media</p>
</footer>
</article>
<!-- Articles can be nested in sections -->
<section>
<h2>Latest Posts</h2>
<article>...</article>
<article>...</article>
</section>Sections vs Articles: When to Use Which?
Understanding when to use section vs article is crucial for semantic HTML. Here's a practical guide to help you choose the right element.
Use SECTION When:
- Grouping thematically related content
- Creating document outline structure
- Content needs context from surrounding elements
- Organizing page layout into logical areas
- Creating hierarchical content structure
Use ARTICLE When:
- Content can stand alone independently
- Content could be distributed separately
- Creating reusable content blocks
- Content makes sense out of context
- Building syndicated content
Decision-Making Questions:
Could this content be removed and still make sense elsewhere?
If yes → article, if no → section
Is this content complete on its own?
If yes → article, if no → section
Would you put this in an RSS feed?
If yes → article, if no → section
Real-World Structure Examples
Here are common website patterns showing how to properly structure content with sections and articles.
Blog Layout Structure:
<main>
<section class="hero">
<h1>My Tech Blog</h1>
</section>
<section class="posts">
<h2>Latest Posts</h2>
<article>
<h3>Understanding JavaScript</h3>
<p>Content...</p>
</article>
<article>
<h3>CSS Grid Guide</h3>
<p>Content...</p>
</article>
</section>
<section class="archive">
<h2>Popular Posts</h2>
<!-- More articles -->
</section>
</main>E-commerce Structure:
<main>
<section class="hero">
<h1>Welcome to TechStore</h1>
</section>
<section class="categories">
<h2>Shop by Category</h2>
<!-- Category links -->
</section>
<section class="featured">
<h2>Featured Products</h2>
<article class="product">
<h3>MacBook Pro</h3>
<p>Product details...</p>
</article>
<article class="product">
<h3>iPhone 15</h3>
<p>Product details...</p>
</article>
</section>
</main>Pro Tips for Structure:
Content Strategy:
- • Plan your content hierarchy first
- • Use headings to create clear outlines
- • Keep related content grouped
- • Make articles self-contained
SEO Benefits:
- • Better content understanding
- • Improved search snippets
- • Enhanced accessibility
- • Cleaner document outline
Accessibility & SEO Benefits
Proper use of semantic elements significantly improves accessibility, SEO, and overall user experience.
Accessibility Benefits:
- Screen Reader Navigation
Users can jump between sections and articles
- Document Outline
Clear content hierarchy for assistive technology
- Semantic Meaning
Content structure has inherent meaning
SEO Advantages:
- Content Understanding
Search engines understand content structure better
- Featured Snippets
Better chance of appearing in search features
- Article Markup
Articles can be enhanced with structured data
Common Mistakes to Avoid:
Section Mistakes:
- • Using sections without headings
- • Wrapping entire page in one section
- • Using section for styling only
- • Confusing section with div
Article Mistakes:
- • Using article for non-standalone content
- • Nesting unrelated articles
- • Missing required heading elements
- • Using article as generic container
Sections and Articles — step by step
Use article for independent content
article wraps content that can stand on its own — a blog post, news article, or product review. If you could syndicate the content to another site, it's a good candidate for article.
🎯 Quick Check
What makes article different from section in HTML5 semantics?
HTML section and article: summary
Key points
- Articles can be nested: comments inside a blog post are articles within an article.
- A
<section>without a heading is usually a sign you need a<div>instead. <aside>is for content related to its surroundings, such as sidebars, pull quotes and "related posts".
Frequently asked questions
›Should I use section or div?
Use <section> when the content forms a distinct part of the document with its own heading. Use <div> for styling wrappers with no meaning.
›Can an article contain sections and sections contain articles?
Yes, both. For example, a "Latest posts" <section> can contain several <article>s, and a long article can be split into <section>s.