Skip to content

<div> - Content Division

Block-level HTML 3.2

The <div> element is a generic container for flow content with no semantic meaning. It’s used to group elements for styling or JavaScript purposes when no other semantic element is appropriate.

Result
<div>
<!-- Content goes here -->
</div>

The <div> element acts as a container without adding any semantic meaning to its contents.

The <div> element supports all global attributes like id, class, style, and data attributes.

<div id="main-content" class="container" data-section="intro">
Content here
</div>
Result
Result
Result
Result
Result
Result
  • No semantic element fits
  • You need a container for styling
  • You need to group elements for JavaScript
  • Creating custom layout structures
Result

Semantic elements are more appropriate:

<article>
<header>
<h1>Article Title</h1>
</header>
<section>
<p>Article content...</p>
</section>
<footer>
<p>Published: 2025-12-11</p>
</footer>
</article>
Instead of…Use…When…
<div class="header"><header>Introductory content
<div class="nav"><nav>Navigation links
<div class="main"><main>Primary content
<div class="article"><article>Self-contained content
<div class="section"><section>Thematic grouping
<div class="aside"><aside>Tangentially related content
<div class="footer"><footer>Footer information
<article>
<header>
<h1>Blog Post Title</h1>
<p>Published on December 11, 2025</p>
</header>
<section>
<h2>Introduction</h2>
<p>Post content...</p>
</section>
<footer>
<p>Tags: HTML, CSS, JavaScript</p>
</footer>
</article>
Result
Result
Result

When using divs for major sections, add ARIA landmarks:

<div role="banner">
<!-- Site header -->
</div>
<div role="navigation">
<!-- Navigation links -->
</div>
<div role="main">
<!-- Main content -->
</div>

Too many nested divs hurt accessibility:

<section class="products">
<article class="product">
<h2>Product Name</h2>
<p>Description</p>
</article>
</section>

Divs have no semantic meaning for screen readers:

<!-- Screen reader: "Product Name, heading level 2. Description" -->
<div class="product">
<h2>Product Name</h2>
<p>Description</p>
</div>
<!-- Screen reader: "Article. Product Name, heading level 2. Description" -->
<article class="product">
<h2>Product Name</h2>
<p>Description</p>
</article>
Result
Result
Result
BrowserVersionNotes
Chrome1+Full support
Firefox1+Full support
Safari1+Full support
Edge12+Full support
IE3+Full support

The <div> element has been supported since HTML 3.2.