HTML Div Element

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