Tutorials HTML Div & Span Elements
Ch 8 / 21 ← Prev Next →
Chapter 8 Beginner 6 min read Core Elements

Div & Span Elements

Div and Span are generic container elements used to group and style HTML content.

🎯 What you'll learn
Use <div> as a block-level container
Use <span> as an inline container
Understand block vs inline elements
Combine with CSS classes for styling
🚀
Sponsored
Learn Full-Stack Development — Join K2 Courses
Live mentoring · Real projects · Placement support · Certificate
Enroll Free
Advertisement
Google Ad — 728×90 Leaderboard

Introduction to Div & Span Elements

This chapter covers Div & Span Elements in depth. Understanding this topic is essential for writing clean, modern HTML. Use the live editor below to experiment as you read.

💡 In This Chapter
You will see real code examples, clear explanations, and a live editor to practice immediately — no setup needed.

Div

Block container.

HTML
<div class="card">
  <h2>Card Title</h2>
  <p>Card content here.</p>
</div>

Span

Inline container.

HTML
<p>My favourite color is <span style="color:orange">orange</span>.</p>

Try It Yourself

Edit the code below and click ▶ Run to see your changes live.

Live Editor
✎ Editor
👁 Preview
Quick Check — Chapter 8

<div> is a __ element while <span> is a __ element.

📄 Chapter Summary
  • Use <div> as a block-level container
  • Use <span> as an inline container
  • Understand block vs inline elements
  • Combine with CSS classes for styling
💡
Sponsored
Master CSS — The Next Step After HTML
56 chapters · Flexbox, Grid, Animations · Free to start
Start CSS →
Advertisement
Google Ad — 300×250 Medium Rectangle
Join WhatsApp Channel