Open In App

Difference between <article> tag and <section> tag

 

Both the tags are semantics tag in HTML 5. In this article, we will discuss the behavior of the <article> and <section> tag. Both the <article> and <section> tags are represented in a similar way but used for some meaning, that meaning is for the browsers and the developers. Both tags can replace each other as there will be no changes to the outputs, but it will be difficult to understand by the developers and the browsers to act on those content. 



<article> Tag: This tag contains independent content that doesn’t require any other context. So the <article> tag can be placed inside the main content. But each of the articles will contain independent content within it. Like YouTube use to contain different kinds of videos on a single page, each video is independent or you can see the course page of GeeksforGeeks each course is independent, each course can have its own page.

 Feature:



<section> Tag: This tag is used to split a page into sections like Introduction, Contact Information, Details, etc and each of these sections can be in a different <section> tag. The <section> tag is introduced to wrap-up the things in a particular section. The <section> tag divides the content into sections and subsections. The section tag is used when requirements of two headers or footers or any other section of documents needed. Section tag grouped the generic block of related content. 

Feature:

Note: Placing <article> tag inside of <section> tag is good practice, like section basically defines the types and the articles will contain the specific contents in that type of section. 

Example: In this example we will use both the tags depending on its behavior like articles that contain a list of independent content and the section tag will contain specific sections on a webpage. 




<!DOCTYPE html>
<!DOCTYPE html>
<html>
 
<head>
    <title>
        article tag over section tag
    </title>
 
    <style>
        .container {
            width: 650px;
            height: auto;
        }
        .section {
            float: right;
        }
        .article {
            float: left;
        }
        h1 {
            color: green;
        }
    </style>
</head>
 
<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <p>A Computer Science Portal</p>
        <div class="container">
            <div class="article">
                <article>
                    <h2>This is article tag</h2>
                    <p>
                        Above header(h2) placed
                        in article tag
                    </p>
                </article>
                <h2>This is non-article tag</h2>
                <p>
                    The header is larger compare
                    to above header
                </p>
            </div>
             
            <div class="section">
                <section>
                    <h2>This is section tag</h2>
                    <p>
                        Above header(h2) placed
                        in section tag
                    </p>
                </section>
                <h2>This is non-section tag</h2>
                <p>
                    The header is larger compare
                    to above header
                </p>
            </div>
        </div>
    </center>
</body>
 
</html>

Output:

  

Choose one over another:

Tags for:

Let us see the differences in a tabular form -:

  <section> <article>
1. The <section> tag defines a section in a document. The <article> tag specifies independent, self-contained content.
2. The <section> tag supports Global attributes It supports Event attributes
3. The <section> tag supports Event attributes. It supports Global attributes
4. The <section> tag represents the generic section of the document or application. The article Tag represents a complete, composition in the document, page, application, or site.
5. The <section> tag is the only block of related content. The <article> tag is a special type of <section>
6.

<section> tag is supported by following browsers -:

Chrome(5.0) , Microsoft Edge(9.0), Firefox(4.0) , Safari (5.0) , Opera Mini (11.5)

It is supported by following browsers -:

Chrome(6.0) , Microsoft Edge(9.0), Firefox(4.0) , Safari (5.0) , Opera Mini (11.1)


Article Tags :