HTML Div Element

Article Summary

Learn how to use the HTML div element to group and structure content with clear and practical examples.

The <div> element is a generic block-level container.
It is used to group content for structure and layout.


Basic Div Example

<div id="container" class="box" title="Content section">
  <h2>Section Title</h2>
  <p>This content is inside a div.</p>
</div>

Attributes Used

  • id → unique identifier
  • class → reusable grouping
  • title → tooltip

When to Use <div>

  • Group related elements
  • Create layout sections
  • Apply styles or scripts

Important Notes

  • <div> has no semantic meaning
  • Use semantic elements when possible
  • <div> is block-level
Was this helpful?