structure

<div>

Generic block-level container with no inherent semantic meaning, used to group content for styling or scripting. Reach for it only when no semantic element (section, article, nav, header) fits the content.

<div class="container">...</div>

Common attributes

Attribute Purpose
class CSS class hook for styling
id Unique identifier for JS/anchors
style Inline CSS declarations
data-* Custom data attributes readable from JS

Examples

<div class="card">Hello</div>

Basic styled container

<div id="app"></div>

Mount point for a JS framework

<div data-user-id="42">Ada</div>

Custom data attribute readable via dataset.userId

Gotcha

Overusing

creates 'div soup' that hurts accessibility and SEO. Prefer semantic elements (section, article, nav, header, footer, main) when they fit.

Related tags

← All HTML tags · CSS selectors · HTML entities