HTML <section> Tag Tutorial - Usage, Syntax,
Attributes and Example

calender-iconPublished: 29 May 2025

clock-icon5-min read





INTRODUCTION

The HTML <section> element is used for general sections within a document. It is used for content that does not have a more precise semantic element to define it. A section should almost always have a heading, with only a few exceptions.

The <section> tag is generally used to group together related parts of a webpage. It helps tell browsers and tools like screen readers that the content inside the section belongs together. This makes your website easier to understand for both people and search engines.

Example:

<section>
  <h2>Introduction</h2>
  <p>Welcome to my blog! Here, I share my thoughts on various topics.</p>
</section>
                    
<section>
  <h2>Latest Posts</h2>
  <article>
    <h3>Understanding HTML5</h3>
    <p>HTML5 introduces many new elements that improve web development.</p>
  </article>
  <article>
    <h3>CSS Tips and Tricks</h3>
    <p>Enhance your styling with these powerful CSS techniques.</p>
  </article>
</section>
Output:

Introduction

Welcome to my blog! Here, I share my thoughts on various topics.



Latest Posts

Understanding HTML5

HTML5 introduces many new elements that improve web development.

CSS Tips and Tricks

Enhance your styling with these powerful CSS techniques.





Usage Guidelines

  • Use <article> for content that can stand alone, like a blog post, comment, or news article.
  • Use <aside> for extra information related to the main content, like related links or an author bio.
  • Use <main> for the main content of the page.
  • Use <div> if you just need a container for styling purposes.


Tag Omission

The HTML <section> element must have both start tag and end tag.



ATTRIBUTES

The <section> element only has global attributes.

Frequently Asked Questions (FAQ)

Should I put <section> inside <article> or <article> inside <section>?
It depends on what the content is:

1. Use <article> inside <section> when:
You have a group of related articles (like blog posts or news items) in a section. The <section> groups them by a common theme (e.g., a "Latest News" section).

2. Use <section> inside <article> when:
Your article has different thematic sections inside it. Each <section> adds structure to the content of the article.

What is the difference between html section and div tag?
Feature <section> <div>
Purpose Groups related content into a thematic section Groups content with no specific meaning
Semantic Meaning Yes – conveys meaning (like a chapter or topic) No – purely structural
SEO & Accessibility Helps search engines and screen readers understand the page No extra meaning for SEO or accessibility
When to Use For meaningful, related content with a heading (e.g., a "Services" section) For generic containers or layout (like a wrapper div)