Section groups related content by topic, normally with a heading. It is useful when an article has meaningful subtopics.
What You Need to Know
Do not choose section only because you want a box around content. A div may be a better styling wrapper when no real section exists.
The goal is not to collect as many tags as possible. Pick the element that best describes what the content really is.
Example: See It in Action
Try this markup in a fresh practice file. The next section explains the parts worth paying attention to.
This is a short HTML fragment. To try it as a webpage, put it inside the body element of a complete HTML document.
<section aria-labelledby="activities-title">
<h2 id="activities-title">Club Activities</h2>
<p>Join us after school.</p>
</section>
Let’s Understand the Example
- Section groups content around a shared topic and usually has a heading.
- An h2 starts a major section beneath the page topic.
- A p groups a paragraph of related text. Start another paragraph for a new thought.
- Aria-labelledby uses one or more existing element ids to name another element.
- Id gives one element a unique name within the page, so a link, label, or script can point to it.
You should see a readable heading and its related content. The heading level tells readers how the ideas fit together, not merely how large the letters look.
What Should You See?
The page should display “Club Activities” as a heading, followed by its related content. Change the heading text and refresh the browser to see the result.
Read only the headings, from top to bottom. Do they tell a sensible story? If not, move sections or choose levels that match the content.
Try It Yourself
- Write a second section with its own clear heading.
- Save your changes, open or refresh the page, and compare the result with the original example.
- Tell a friend what your change did. If you are not sure, undo it, refresh the page, and compare.
Common Beginner Mistakes
- Adding a section element around each paragraph without a useful heading.
- Avoid picking tags just for their default bold, italic or spaced appearance. Use CSS for presentation.
Key Takeaways
- Section groups related content by topic, normally with a heading.
- Section groups content around a shared topic and usually has a heading.
- Do not choose section only because you want a box around content. A div may be a better styling wrapper when no real section exists.