html
  1. html-section-tag

HTML <section> Tag

  • The <section> tag in HTML represents a standalone section of content that is semantically and thematically related to other content on the same page.
  • The section typically has its own heading and may include various types of content.

Syntax

The basic syntax for using the <section> tag in HTML is as follows:

<section>
  <!-- content goes here -->
</section>

Example

Here's an example of how the <section> tag can be used in HTML:

<main>
  <h1>My Blog</h1>
  <section>
    <h2>Posts</h2>
    <article>
      <h3>Post 1</h3>
      <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
    </article>
    <article>
      <h3>Post 2</h3>
      <p>Aliquam et laoreet mauris. Nullam at ante vulputate, varius sapien id, faucibus est.</p>
    </article>
  </section>
  <section>
    <h2>About Me</h2>
    <p>My name is John Doe and I'm a blogger who loves to write about various topics.</p>
  </section>
</main>
Try Playground

Explanation

The <section> tag is used to divide the content on a webpage into distinct and semantically related sections. The tag is often used within the <body> tag and is typically accompanied by a heading (<h1>-<h6>) that describes the contents of the section. The section can contain various types of content, such as text, images, videos, and other HTML tags.

The purpose of the <section> tag is to provide structural information to assistive technology, browsers and search engine crawlers in understanding the content and context of the page.

Use

The <section> tag is most commonly used to organize and group related content, such as blog posts, articles, product descriptions, or contact information into different sections. Using the <section> tag helps to break long pages into smaller, more manageable blocks of information that are easier to read and understand.

Important Points

  • The <section> tag should be used when there is a semantic and thematic grouping of content on a page.
  • Each <section> element should have its own heading (<h1>-<h6>), which is used to describe the contents of the section.
  • A single web page can have multiple <section> tags, but each <section> element should be self-contained and not overlap with other sections.
  • The <section> tag does not have any specific style or default behavior. Its function is purely semantic and meant to describe the content.

Summary

The <section> tag in HTML is used to define a stand-alone section of content on a webpage that is both semantically and thematically related to other content on the same page. By using this tag, you can provide semantic information that helps to organize and understand the content of your web page. The tag is an important part of creating a well-structured web page, and it is recommended to use it whenever there is a semantic grouping of content.

Published on: