D DevBrainBox

HTML5 Div Span

HTML

What are <div> and <span> in HTML5?

They are generic container elements used to group other HTML content.

They have no semantic meaning on their own — they’re purely structural, used mainly for styling with CSS or scripting with JavaScript.

<div> – Block-level container

Definition:

  • A block-level element.
  • Starts on a new line and stretches to the full width of its parent container.

Use cases:

  • Group sections of a page.
  • Create layouts (columns, rows, wrappers).

Apply styles or scripts to an entire block of content.

<div>
  <h2>About Us</h2>
  <p>We provide tech solutions for businesses.</p>
</div>  

<span> – Inline container

Definition:

  • An inline element.
  • Does not start on a new line.
  • Only takes up as much width as its content.

Use cases:

Style or manipulate small pieces of text inside other elements.

<p>Our CEO is <span class="highlight">Jane Doe</span> and she loves innovation.</p>

Comparison Table

TagTypeStarts on new line?Typical use
<div>Block-levelYesGrouping larger blocks (like sections, layouts)
<span>InlineNoWrapping small parts of text or inline elements

On this page