<div> Tag in HTML

The <div> tag is a block-level HTML element used to group and organize other elements. It doesn’t provide any specific styling on its own but is primarily used as a container for CSS styling, JavaScript targeting, and layout purposes. By assigning a class or id to a <div>, you can apply specific styles or scripts to that section of the page.

Key Points on <div> Tag:

Syntax of <div> Tag:

Syntax Example

<div class="container">
            <p>Content goes here...</p>
        </div>

Example of <div> Tag in HTML:

This example demonstrates how to use the <div> tag to create a styled container with text and nested elements.

Code Example


        <div class="box">
            <h1>Welcome to the Div Container</h1>
            <p>This is an example of content inside a <div> element.</p>
        </div>
                

Output

Welcome to the Div Container

This is an example of content inside a
element.

The <div> tag is a fundamental building block in HTML. It is commonly used for layout purposes, allowing developers to group elements into sections that can be styled or scripted as needed.