Understanding the <section> and <article> Tags in HTML

theenobledev
4 min readMar 23, 2023

--

Introduction

HTML provides many tags that help define the structure and content of a web page. In this tutorial, we’ll focus on two of these tags — <section> and <article>. These tags are important for organizing and categorizing content, and understanding how they work is essential for building well-structured web pages. By the end of this tutorial, you’ll be able to use <section> and <article> tags to define the main content sections of your web page.

Prerequisites

Before starting this tutorial, you should have a basic understanding of HTML and how to create a web page. If you need to brush up on HTML, check out the W3Schools HTML tutorial (https://www.w3schools.com/html/).

Objectives

By the end of this tutorial, you will be able to:

  • Understand the purpose of the <section> and <article> tags
  • Know when to use <section> and <article> tags
  • Use the <section> and <article> tags to structure your web page content

Materials: To complete this tutorial, you will need a code editor and a web browser.

Step-by-Step Instructions

  1. Understanding the <section> tag The <section> tag is used to define a section of a web page that groups together related content. This tag is often used to divide a page into sections, such as a header, main content, and footer.

Here’s an example of how to use the <section> tag:

<section>
<h2>Main Content</h2>
<p>This is the main content section of the web page.</p>
</section>

In this example, we’ve created a <section> tag with a heading and a paragraph. This section is labeled as the main content section of the web page.

  1. Understanding the <article> tag The <article> tag is used to define a self-contained piece of content that can be reused or distributed independently. This tag is often used for blog posts, news articles, and product listings.

Here’s an example of how to use the <article> tag:

<article>
<h2>How to Bake a Cake</h2>
<p>This is a step-by-step guide on how to bake a cake.</p>
</article>

In this example, we’ve created a <section> tag with a heading and a paragraph. This section is labeled as the main content section of the web page.

  1. Understanding the <article> tag The <article> tag is used to define a self-contained piece of content that can be reused or distributed independently. This tag is often used for blog posts, news articles, and product listings.

Here’s an example of how to use the <article> tag:

<article>
<h2>How to Bake a Cake</h2>
<p>This is a step-by-step guide on how to bake a cake.</p>
</article>

In this example, we’ve created an <article> tag with a heading and a paragraph. This article is about how to bake a cake and can be reused or distributed independently.

3. Using <section> and <article> together You can use <section> and <article> tags together to create a well-structured web page. Here’s an example of how to use both tags together:

<section>
<h2>Main Content</h2>
<article>
<h3>Article 1</h3>
<p>This is the first article in the main content section.</p>
</article>
<article>
<h3>Article 2</h3>
<p>This is the second article in the main content section.</p>
</article>
</section>

In this example, we’ve created a <section> tag with a heading and two <article> tags. Each <article> tag contains a heading and a paragraph.

Tips and Troubleshooting

  • Use the <section> tag to group related content together
  • Use the <article> tag to define a self-contained piece of content
  • Be consistent in your use of <section> and <article> tags to ensure a well-structured web page

Conclusion

In this tutorial, we’ve learned about the <section> and <article> tags in HTML. These tags are important for organizing and categorizing content, and understanding how they work is essential for building well-structured web pages. By using the <section> tag, you can group related content together, and by using the <article> tag, you can define a self-contained piece of content that can be reused or distributed independently.

By following the step-by-step instructions in this tutorial, you should now be able to use <section> and <article> tags to structure the main content sections of your web page. Remember to be consistent in your use of these tags to ensure a well-structured web page.

Further Resources

To learn more about HTML tags and how to use them, check out the links below. You can also explore other HTML tags, such as <div>, <nav>, and <footer>, to further improve the structure of your web pages.

Follow me on Tiktok📱@thee_noble_dev

Follow me on Instagram 📱 @thee_noble_dev

Subscribe to my youtube channel for more📱 @thee_noble_dev

--

--

theenobledev

Mastering the art of code & words. Simplifying tech for you.