HTML Tags

HTML <div> Tag

The <div> tag defines a division or section in an HTML document.
It is a block-level container used to group content for styling (CSS) or scripting (JavaScript).

It is one of the most commonly used HTML tags.

Syntax

<div>
    Content goes here...
</div>

Attributes

AttributeDescription
idSpecifies a unique identifier for the <div>
classAssigns a class name for CSS styling
styleAdds inline CSS styles
titleAdds tooltip text
hiddenSpecifies that the element should be hidden
contenteditableSpecifies whether content inside <div> can be edited
draggableSpecifies whether the <div> is draggable
langSpecifies language

Example

<!DOCTYPE html>
<html>
<head>
    <title>DIV Example</title>
    <style>
        .box {
            width: 200px;
            padding: 20px;
            background-color: lightblue;
            border: 2px solid #333;
            margin-bottom: 20px;
        }
    </style>
</head>
<body>

    <h2>DIV Example</h2>

    <div class="box">
        This is a content box inside a DIV.
    </div>

    <div class="box">
        Another DIV with the same CSS class.
    </div>

</body>
</html>

Output

Browser Output

A page showing two light-blue colored rectangular boxes with text.
Use our Tryit Editor to see the output.

Browser Support

Chrome
Chrome
Firefox
Firefox
Edge
Edge
Safari
Safari
Opera
Opera
IE
IE9+
✅Yes✅Yes✅Yes✅Yes✅Yes✅Yes

Notes

  • <div> is a block-level element; it starts on a new line.
  • It is the most common container for CSS layout design.
  • In modern HTML5, semantic elements like <header>, <section>, <article>, <footer>, etc. are preferred over <div> for structure.
  • <div> should be used mainly as a generic container when no semantic element fits.

Conclusion

The <div> tag is a fundamental block container used to group and style HTML content. While newer semantic tags provide meaning, <div> remains essential for layout and design due to its flexibility.

Sign In Form

User your email and password to singn in

Don’t have an account, signup here : 

HTML5 & CSS3

Tools and Tutorials

Want a Website

Want a website for your business ?

Please fill out the details below, so we can reach out to you.

Registration Form

Signup to track your record and much more.

We have sent you an email with a registration link. Please click the link to verify your email address, or enter the 6-digit OTP provided in the email.

Didn't receive the OTP. Regenerate OTP Resend