Div & Span

All HTML topics
∙ Chapter 13

Div & Span

These containers have no visual appearance — they exist purely for grouping content to apply CSS or JavaScript.

📦The key difference

<div> is block-level — takes the full width and starts on a new line. Use it for layout sections and boxes.

<span> is inline — only takes the space of its content, lives inside text. Use it to style a specific word or phrase in a sentence.

divspan.php
📝 Edit Code
👁 Live Preview
💡 <div> = layout blocks. <span> = inline styling. Both invisible without CSS!