Codectionary / Developer documentation / HTML

<section>

The <section> element groups related content that typically has its own heading, representing a distinct thematic section of a document — like a chapter, tab panel, or a chunk of a landing page. Unlike <div>, which carries no semantic meaning, <section> tells browsers and assistive technology that its content forms a standalone, related group. If content does not have a natural heading or is not thematically distinct, a plain <div> is usually the better choice.

Syntax

<section>
  <h2>Section Title</h2>
  <p>Section content...</p>
</section>

Examples

Landing Page Sections

Breaking a page into distinct thematic sections.

<section>
  <h2>Features</h2>
  <p>Everything you need to learn to code.</p>
</section>

<section>
  <h2>Pricing</h2>
  <p>Free forever for individual learners.</p>
</section>

Section Within an Article

Using sections to divide a long article into parts.

<article>
  <h1>The Complete Guide to Flexbox</h1>
  <section>
    <h2>What is Flexbox?</h2>
    <p>Flexbox is a one-dimensional layout model...</p>
  </section>
  <section>
    <h2>Main Properties</h2>
    <p>justify-content, align-items, and flex-direction...</p>
  </section>
</article>

Styled Section

A visually separated content section.

<section style="padding: 40px 20px; background: #f9fafb; border-radius: 12px;">
  <h2 style="margin-bottom: 12px;">Why Choose Us</h2>
  <p>We focus on practical, hands-on learning.</p>
</section>

Best practices

  • Only use <section> when the content is thematically related and would make sense with its own heading
  • If you just need a styling hook with no semantic meaning, use <div> instead
  • Give each <section> a heading (<h2>-<h6>) so it makes sense in a document outline
  • Do not use <section> as a wrapper purely for CSS layout purposes — that dilutes its semantic value

At a glance

Purpose
Structure and meaning for web content
File extension
.html · .htm
Runs in
Web browsers
Usually used with
CSS and JavaScript

Specifications & further reading

Related HTML documentation