👀 Live Preview
A page divided into three thematic sections:
Introduction
Your introductory content here.
Main Content
Your main content goes here.
Conclusion
Summarize your key points in this section.

The <section> tag is a powerful semantic element for defining thematic sections within a document. This guide covers syntax, attributes, structuring content, accessibility, and best practices for beginners.
Group related content.
Block-level element.
Style and target.
Chapters & groups.
Clear page outline.
When to use section.
<section> Tag?The <section> tag is a block-level element that helps structure and organize content on a webpage. It groups thematically related content, making the document’s structure easier to understand for users, search engines, and assistive technology.
Use section when content forms a distinct thematic group with its own heading — not merely for styling wrappers.
Each section should typically include a heading (h1–h6). If you only need a generic container without semantic meaning, use <div> instead.
Enclose the content you want to group within opening and closing section tags:
<section>
<!-- Your content here -->
</section>section when possible.section for thematic grouping, not as a replacement for div styling.section elements is valid when a subsection belongs to a larger section.section as a generic page wrapper — use main or body content areas.| Topic | Code Snippet | Notes |
|---|---|---|
| Basic section | <section>...</section> | Thematic group |
| With heading | <h2> inside section | Recommended |
| Styling hook | class="intro" | Global attribute |
vs article | section = grouping | Not standalone |
vs div | section = semantic | div = generic |
| Landmark role | region when named | Exposed to AT |
<section> vs <article> vs <div>| Element | Purpose | Example |
|---|---|---|
<section> | Thematic group within a page | Introduction, features list, contact form group |
<article> | Self-contained, distributable content | Blog post, news story, product card |
<div> | Generic container, no semantic role | Layout grid, icon wrapper, CSS hook |
| Rule of thumb | If it could appear alone in an RSS feed, use article | |
The <section> tag has no tag-specific attributes. It supports global attributes like class and id for styling and targeting with CSS or JavaScript.
<section class="main-section" id="intro-section">
<!-- Your content here -->
</section>class / id GlobalApply styles or target specific sections with CSS selectors and JavaScript.
class="main-section" id="intro-section"lang OptionalDeclare the language of content inside the section when it differs from the page.
lang="es"aria-labelledby A11yNames the section landmark for screen readers when multiple unnamed sections exist.
aria-labelledby="features-heading"style / data-* OptionalInline styles or custom data attributes for templates and JavaScript hooks.
data-tab="overview"Divide pages into clear, thematic sections with semantic HTML and beginner-friendly examples.
A page divided into three thematic sections:
Your introductory content here.
Your main content goes here.
Summarize your key points in this section.
The primary purpose of <section> is to divide your document into thematic sections that make sense in the context of your webpage.
Use section to organize content such as articles, chapters, or any grouping that forms a distinct part of your page. Each section should include a descriptive heading.
<section>
<h2>Introduction</h2>
<p>Your introductory content here.</p>
</section>
<section>
<h2>Main Content</h2>
<p>Your main content goes here.</p>
</section>
<section>
<h2>Conclusion</h2>
<p>Summarize your key points in this section.</p>
</section>Using section tags properly enhances accessibility and search engine optimization. Screen readers and search engines better understand your content when it is organized with semantic elements and clear headings.
<main>
<section aria-labelledby="features-heading">
<h2 id="features-heading">Product Features</h2>
<p>Organized sections help assistive technology navigate your page.</p>
</section>
</main>section should have an h1–h6 that describes its topic.aria-labelledby when the section heading is not sufficient for screen reader navigation.nav, aside, or article when those roles fit better than a generic section.Related paragraphs, lists, and media are wrapped in a section element.
When named, the section becomes a region landmark for assistive technology.
Use class or id to layout and style each thematic group.
Users, crawlers, and screen readers all benefit from a logical document outline.
The <section> tag is supported in all modern browsers. Internet Explorer 9+ recognizes the element; IE 8 and below treat it as a generic block without semantic meaning.
From IE 9 to the latest browsers — section is a core HTML5 sectioning element.
Bottom line: Test in target browsers, but <section> is safe for all modern projects.
Incorporating the <section> tag into your HTML documents improves both the structure of your webpage and its accessibility. By embracing semantic elements like section, you contribute to a more organized and user-friendly web.
section when grouping related content thematicallysection only for styling — use div insteadarticle when content is self-contained and distributable<section>Bookmark these before you structure your next page.
Organize content.
Purposeh2–h6 inside.
StructureStyle & target.
AttributesGrouping only.
ComparisonClear outline.
BenefitsModern safe.
Compatibilitysection carries semantic meaning and should include a heading. div is a generic container with no semantic role.article is for self-contained content like blog posts. section groups content within a page.class, id, and aria-labelledby.section; IE 8 and below treat it as a generic block.Practice <section> with class, id, and multi-section layouts in the Try It editor.
6 people found this page helpful