HTML <section> Tag

Beginner
6 min read
Updated: Nov 2026
4 examples
Live preview

Definition and Usage

The <section> element represents a generic standalone section of a document when no more specific element fits. Typical uses: chapters, themed blocks, or grouped form fields that share one topic.

Give each section a heading whenever you can. Prefer <article> for self-contained posts, <nav> for major menus, <aside> for complementary notes, <main> for the page’s primary content, and <div> when you only need a styling wrapper.

Baseline · Widely available.

Not deprecated. Sectioning content support has been stable across browsers since about July 2015.

Not a styling box.

If the only reason for the wrapper is CSS or JS hooks, use <div>. Reserve <section> for thematic meaning.

HTML Syntax

syntax.html
<section> …heading and content…</section>

Both start and end tags are required. Flow content is allowed inside. Do not place a <section> inside an <address>.

Attributes

<section> has no element-specific attributes. Use the global attributes you need most often:

AttributeDescriptionTry it
idUnique target for in-page links (e.g. href="#pricing")Try it
classHooks for CSS shared across similar sectionsTry it
aria-labelledbyPoints at a heading id so the section becomes a named region landmarkTry it
langLanguage of this section when it differs from the pageGlobal attr

Global Attributes

The <section> tag also supports the Global Attributes in HTML.

Live Preview

Switch common section patterns and see the structure update live.

Real <section> markup. Apply a pattern to compare structures.

Preview

Introduction

A thematic group with its own heading.

Basic — one section with a clear heading.

HTML Examples

Short, copy-ready snippets. Use Try It Yourself for a live editor.

Example 1 — Basic Section

One thematic block with a heading and body text.

HTML
<section id="intro" class="chapter">
  <h2>Introduction</h2>
  <p>
    A section groups related content under one topic.
    Always include a heading when you can.
  </p>
</section>
Try It Yourself

How It Works

  1. Open <section>. Marks one thematic group.
  2. Add id / class when you need deep links or styles.
  3. Put a heading first so people and assistive tech can identify the topic.
  4. Close the tag. Both start and end tags are required.

Example 2 — Page Chapters

Split a document into several thematic sections, each with its own heading.

HTML
<h1>Choosing an Apple</h1>

<section>
  <h2>Introduction</h2>
  <p>A short guide to picking the right apple.</p>
</section>

<section>
  <h2>Criteria</h2>
  <p>Consider size, color, firmness, and sweetness.</p>
</section>
Try It Yourself

How It Works

  1. Page title can sit outside the sections (often an h1).
  2. One theme → one <section> with a matching h2.
  3. Keep siblings parallel — same heading level for peer chapters.
  4. Do not wrap the whole page in a single unnamed section.

Example 3 — Named Region Landmark

Tie the section to its heading with aria-labelledby so assistive tech can jump to a named region.

HTML
<main>
  <section aria-labelledby="features-heading">
    <h2 id="features-heading">Product Features</h2>
    <p>Named sections help screen-reader users scan landmarks.</p>
  </section>
</main>
Try It Yourself

How It Works

  1. Give the heading an id (e.g. features-heading).
  2. Set aria-labelledby on the section to that same id.
  3. Implicit role becomes region because the section now has an accessible name.
  4. Avoid dozens of named regions — only label sections that deserve landmarks.

Example 4 — Nested Sections

Nest a subsection when it belongs inside a larger thematic group. Keep heading levels orderly.

HTML
<section>
  <h2>Getting Started</h2>
  <p>Install the tools, then learn the basics.</p>

  <section>
    <h3>Install</h3>
    <p>Download the starter kit and open the project folder.</p>
  </section>

  <section>
    <h3>First page</h3>
    <p>Create an index.html file and add a heading.</p>
  </section>
</section>
Try It Yourself

How It Works

  1. Outer section covers the parent topic (h2).
  2. Inner sections are real subsections of that topic.
  3. Step heading levels down (h2 → h3) — do not skip for looks.
  4. Prefer specific tags if an inner block is really nav, aside, or article.

Edge Cases & Pitfalls

Most mistakes treat section as a generic box or skip headings.

semantics

Prefer a more specific element

Menus → <nav>, side notes → <aside>, standalone posts → <article>, primary page content → <main>.

styling

Do not use section as a CSS wrapper

If the box has no thematic meaning, use <div>. Semantics stay in HTML; layout stays in CSS.

a11y

Identify with a heading

Document sections without headings confuse outlines and SEO. Headless sections are rare (some UI toolbars).

landmarks

Nameless sections are not regions

Without an accessible name, section maps to a generic role. Name only the sections that should appear as landmarks.

address

Never inside <address>

The HTML spec forbids <section> as a descendant of <address>.

Browser Support

The <section> element is core HTML5 sectioning content in every major browser. It is not a Node.js, Deno, or Bun API.

✓ Baseline · Widely available

<section>

Widely available since about July 2015. Chrome, Firefox, Safari, Edge, and Opera all support section as a sectioning element. With an accessible name it exposes as a region landmark.

98% Global support (approx.)
Google Chrome All
Full support
Mozilla Firefox All
Full support
Apple Safari All
Full support
Microsoft Edge All
Full support
Opera All
Full support
Samsung Internet All
Full support
Internet Explorer 9+
Supported
<section> Widely supported

Bottom line: Safe to use everywhere for thematic grouping. Pair each section with a heading for the best accessibility and SEO.

Key Takeaways

  • Role: <section> marks a thematic group when no better element fits.
  • Heading: identify almost every section with an h* child.
  • vs article / div: standalone → article; style-only box → div; thematic chapter → section.
  • Landmark: named sections become region; unnamed ones stay generic.

One line: use <section> for themed chapters with headings — not as a generic layout box.

Default CSS Settings

Browsers treat section as a block sectioning element. A typical user-agent idea:

default.css
section {
  display: block;
}

Borders, cards, and spacing come from your CSS — semantics stay in the HTML.

Frequently Asked Questions

The section element marks a generic standalone section of a document when no more specific semantic element fits — for example chapters, grouped form fields, or themed blocks that belong together under a heading.
No. section only supports the Global Attributes in HTML (such as id, class, and lang). Use a heading or aria-labelledby when you need a clear accessible name for a region landmark.
Use article when the block could stand alone or be syndicated (a blog post or news story). Use section to group related content that is part of a larger page but not necessarily reusable on its own.
section is semantic thematic grouping and should usually include a heading. div is a generic container with no meaning — prefer it for layout or styling wrappers.
Yes in almost all document cases. MDN and the HTML living standard expect sections to be identified with a heading. Headless sections are rare and mainly for certain UI toolbars.
If the section has an accessible name (for example via aria-labelledby pointing at its heading), its implicit role is region. Without a name, it is exposed as generic — so nameless sections do not clutter the landmark list.

Next: select

Build dropdown lists with options users can choose from.

select tutorial →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

11 people found this page helpful