HTML: div
The <div> element is a generic container used when no more meaningful semantic element describes the group.
What you will learn
- How to group elements for CSS or JavaScript
- When a semantic element is a better choice
- How to avoid adding meaningless containers
Minimal example
<div class="card">
<h2>A product</h2>
<p>A short description.</p>
</div>The class lets CSS style the group, but <div> does not tell browsers that the content is an article, navigation, or a heading group.
Common mistakes
- Do not replace every meaningful element with
<div>; meaning helps accessibility and maintenance. - Choose
<article>for an independent item and<section>for a titled theme.