DEV Community

Cover image for Understanding HTML Semantic Elements: Exploring the Purpose of <div>, <section>, and <article>
vayola pradeep
vayola pradeep

Posted on

1 1 1 1

Understanding HTML Semantic Elements: Exploring the Purpose of <div>, <section>, and <article>

What is <div>,<section> & <article>

<div>, <section>, and <article> are HTML elements used for structuring and organizing content within a web page. Each of these elements serves a specific purpose in dividing content and improving the semantic structure of a webpage.

Image description

1. <div> Element:

The <div>element is a generic container used to group and style elements together for layout and styling purposes. It doesn't carry any inherent meaning on its own and is often used to create divisions or sections within a webpage that can be targeted with CSS for styling or JavaScript for interactivity.The syntax for using the <div> element in HTML is as follows:

html

<div>
    <!-- Your content goes here -->
</div>
Enter fullscreen mode Exit fullscreen mode

For example:

<div class="container">
    <h1>Welcome to codewithevayola</h1>
    <p>Its me Vayola </p>
    <img src="https://res.cloudinary.com/dhfay42ie/image/upload/v1692137113/WhatsApp_Image_2023-08-15_at_6.04.19_PM_jlfydk.jpg" alt="An image">
</div>
Enter fullscreen mode Exit fullscreen mode

Image description

  1. <section>Element:

The <section>element is used to define a thematic grouping of content, such as a chapter, a block of related content, or a self-contained portion of a webpage. It helps to improve the semantic structure of the page and makes it easier for search engines and assistive technologies to understand the content's context.The syntax for using the <section> element in HTML is as follows:

<section>
    <!-- Your content goes here -->
</section>
Enter fullscreen mode Exit fullscreen mode

For Example:

<section>
    <h2>About Me</h2>
    <p>Passionate Full Stack Dev crafting seamless web solutions</p>
</section>

<section>
    <h2>Services</h2>
    <ul>
        <li>Web Design</li>
        <li>Web Development</li>
    </ul>
</section>
Enter fullscreen mode Exit fullscreen mode

Image description

  1. <article> Element:

The <article> element represents a self-contained and independently distributable piece of content. It's typically used for blog posts, news articles, forum posts, or any content that can stand alone and make sense when taken out of context. It's beneficial for improving SEO and making content more accessibleThe syntax for using the <article> element in HTML is as follows:

<article>
    <!-- Your content goes here -->
</article>
Enter fullscreen mode Exit fullscreen mode

For Example:

<article>
    <h2>what is Git</h2>
    <p>Git is a distributed version control system (VCS) designed to track changes in source code during software development. </p>
    <p>It allows multiple developers to collaborate on projects by providing a framework for managing and recording changes to the codebase over time</p>
</article>
Enter fullscreen mode Exit fullscreen mode

Image description

Sentry blog image

How I fixed 20 seconds of lag for every user in just 20 minutes.

Our AI agent was running 10-20 seconds slower than it should, impacting both our own developers and our early adopters. See how I used Sentry Profiling to fix it in record time.

Read more

Top comments (0)

Cloudinary image

Optimize, customize, deliver, manage and analyze your images.

Remove background in all your web images at the same time, use outpainting to expand images with matching content, remove objects via open-set object detection and fill, recolor, crop, resize... Discover these and hundreds more ways to manage your web images and videos on a scale.

Learn more

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay