0
0
HtmlConceptBeginner · 3 min read

What is the Section Tag in HTML: Definition and Usage

The <section> tag in HTML defines a thematic grouping of content, like a chapter or a part of a page. It helps organize content into meaningful sections for both users and search engines.
⚙️

How It Works

The <section> tag works like a container that groups related content together. Imagine a book divided into chapters; each chapter covers a specific topic. Similarly, a <section> groups content that shares a common theme or purpose.

This helps browsers, search engines, and assistive technologies understand the structure of your page better. It also improves accessibility by making it easier for screen readers to navigate through different parts of the content.

💻

Example

This example shows two sections on a webpage: one for an introduction and one for a news article.

html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Section Tag Example</title>
</head>
<body>
  <section>
    <h2>Introduction</h2>
    <p>Welcome to our website. Here you will find useful information.</p>
  </section>
  <section>
    <h2>Latest News</h2>
    <p>Today we launched a new feature for our users.</p>
  </section>
</body>
</html>
Output
Introduction Welcome to our website. Here you will find useful information. Latest News Today we launched a new feature for our users.
🎯

When to Use

Use the <section> tag when you want to group related content that forms a distinct part of your page. For example, sections can be used for chapters, tabs, or different topics on a single page.

It is especially useful for long pages with multiple topics, helping users and search engines understand the page layout. Avoid using <section> for small or generic containers; use <div> instead if the content is not thematic.

Key Points

  • The <section> tag groups related content with a common theme.
  • It improves page structure and accessibility.
  • Each section usually has a heading like <h2> to describe its content.
  • Use it for meaningful parts of a page, not just for styling.