HTML Tutorial

HTML Tag: <section>

Usage of <section>

The <section> tag represents a standalone section within a document. It's used to organize content into logical groups, such as chapters, headers, and footers.

Attributes of <section>

  • id: Assigns a unique identifier to the section.
  • class: Applies a class name to the section for styling purposes.

Examples with <section>

  • Header Section: <section id="header"><h1>My Header</h1></section>
  • Chapter Section: <section id="chapter1"><h2>Chapter 1</h2><p>...</p></section>
  • Footer Section: <section id="footer"><p>Copyright 2023</p></section>

Exploring the <section> tag

<html>
<head>
  <title>Exploring the <section> Tag</title>
</head>
<body>
  <section id="main">
    <h1>Main Section</h1>
    <p>This is the main content of the page.</p>
  </section>
  <section id="sidebar">
    <h2>Sidebar</h2>
    <p>This is the sidebar content.</p>
  </section>
</body>
</html>

In this example:

  • The main content is contained within the <section id="main"> element.
  • The sidebar content is contained within the <section id="sidebar"> element.