The <div> element is the generic container for flow content. Alone it does not change meaning or layout. Style it with CSS, or place it inside a Flexbox/Grid parent, when you need a hook for grouping.
Set a unique id on the target <div> (one per page).
Link with a fragment such as href="#intro".
Activate the link to scroll to that container.
Prefer semantic targets (<section id="…">) when the region has meaning.
Example 4 — Prefer a Semantic Element
When content is a thematic grouping, use <section> instead of a bare <div>.
HTML
<!-- Prefer this when it is a real section -->
<section>
<h2>Pricing</h2>
<p>Plans start at $0 for learning projects.</p>
</section>
<!-- Use div only when no semantic tag fits -->
<div class="layout-row">
<p>Generic layout wrapper.</p>
</div>
Ask what the content is (section, article, nav, aside, and so on).
Pick the matching semantic tag when one fits.
Fall back to <div> for pure layout or styling hooks with no extra meaning.
Keep accessibility in mind:<div> is role generic, not a landmark.
Edge Cases & Pitfalls
Most div problems come from overusing it or treating it as a landmark.
semantics
Avoid “div soup”
Nested empty wrappers hurt readability. Prefer semantic tags and only as many <div>s as layout needs.
a11y
Not a landmark
Implicit role is generic. Use <main>, <nav>, or labeled regions for structure screen readers can find.
inline
Do not wrap words in div
For a phrase inside a sentence, use <span>. A <div> breaks to a new line by default.
obsolete
Skip align
Presentational alignment belongs in CSS. The align attribute on <div> is obsolete.
aria
Be careful with ARIA on div
You may assign many roles, but prefer native elements. A role on <div> still needs correct keyboard and naming support.
Compatibility
Browser Support
The <div> element is core HTML in every browser. It is not a Node.js, Deno, or Bun API.
✓ Baseline · Widely available
<div>
Widely available since about July 2015 (and long before as a generic container). Chrome, Firefox, Safari, Edge, and Opera all support it fully.
98%Global support (approx.)
Google ChromeAll
Full support
Mozilla FirefoxAll
Full support
Apple SafariAll
Full support
Microsoft EdgeAll
Full support
OperaAll
Full support
Samsung InternetAll
Full support
Internet ExplorerAll
Supported
<div>Widely supported
Bottom line: Safe to use everywhere as a generic container. Prefer semantic elements when they describe the content better.
Remember
Key Takeaways
Role:<div> groups flow content; it has no meaning by itself.
Hooks: style and script with class and id; layout with CSS Flexbox or Grid.
Semantics first: choose section, article, nav, and friends when they fit.
Avoid: obsolete align, and wrapping inline text in div instead of span.
One line: use <div> as a last-resort generic box, not as a substitute for meaning.
UA style
Default CSS Settings
User-agent stylesheets treat div as a block box with no extra chrome:
default.css
div {
display: block;
}
Margins, padding, borders, and Flexbox/Grid come from your CSS (or from a parent layout), not from the tag itself.
Frequently Asked Questions
The div element is a generic container for flow content. It has no meaning by itself. Use it to group content for styling, scripting, or layout when no semantic element fits better.
No element-specific attributes. Use global attributes such as class, id, lang, and title. The old align attribute is obsolete — use CSS instead.
div is a block-level (flow) container that starts on a new line by default. span is an inline container for text-level phrasing content.
No. Prefer semantic elements like header, nav, main, section, article, or aside when they match the content. Reach for div only when you need a generic wrapper.
div has an implicit ARIA role of generic. It does not announce a landmark. Do not rely on bare divs for page structure that assistive tech should recognize.
Add class or id, then apply CSS (including Flexbox or Grid on the div or its parent). Avoid obsolete align and heavy inline styles for large projects.