- Home
- /
- Tutorials
- /
- HTML Tutorial
- /
- HTML <section> Tag
HTML Tags
HTML <section> Tag
The section tag groups content on one theme under its own heading, like the chapters of a page: "About us", "Our services", "Pricing". The quick test: if you cannot give it a heading, it should probably be a div.
<section> is one of the semantic layout tags. It is easy to overuse, because it sounds like "a part of the page", and every part of a page is a part.
Syntax
html
<section>
<!-- Thematically related content with heading -->
</section>It has no attributes of its own, only the global ones such as id, class, style and title. An id is useful for linking straight to a section, like href="#services".
Example
html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Section Tag Example</title>
</head>
<body>
<h1>Website Overview</h1>
<section style="border: 1px solid #ccc; padding: 15px; margin-bottom: 20px;">
<h2>About Us</h2>
<p>We are a team of web developers specializing in HTML, CSS, and JavaScript.</p>
</section>
<section style="border: 1px solid #ccc; padding: 15px;">
<h2>Our Services</h2>
<p>We provide website design, development, and maintenance services for businesses.</p>
</section>
</body>
</html>Two boxes, "About Us" and "Our Services", each with its own heading and text. The borders come from inline styles; <section> itself looks like nothing.
section, article or div?
<article>if the content would make sense on its own, copied to another site: a blog post, a product card, a comment. See the article tag.<section>if it is one themed part of something bigger and has a heading.<div>if you only need a box for styling or layout, with no meaning.
Sections and articles can nest both ways: a long article can be split into sections, and a section called "Latest posts" can hold several articles.
Browser Support
Chrome | Edge | Firefox | Safari | Opera | IE9+ |
|---|---|---|---|---|---|
| Yes | Yes | Yes | Yes | Yes | Yes |
Good to know
- Start every section with a heading (
<h2>to<h6>), so its topic is clear to screen readers that list headings. - A section with an accessible name, such as an
aria-labelledbypointing at its heading, becomes a "region" landmark that screen reader users can jump to. - Do not wrap a section around a single paragraph just to add a margin. Use a class on the paragraph.
HTML <section> Tag exercises
Group a topic
Make a section with the level 2 heading Pricing and the paragraph Simple plans.
Result
