SA-21/06, C-11, Asapur, Varanasi, UP support@kamaldnp.com +91 8318013442
Lesson 20 of 30

HTML Div

2 min read · Free · No login needed

The <div> tag is the most used element in web design. It is a generic block-level container: it has no meaning of its own, it adds no styling by itself, and it simply groups other elements together so you can style them or move them as one unit.

What divs are for

  • Layout: dividing a page into header, sidebar, main content, and footer areas.
  • Grouping: wrapping a heading, a paragraph, and a button that belong together — for example, one course card.
  • Styling: giving a group a background, a border, padding, or a width through a class.
  • JavaScript: giving a group an id so a script can show it, hide it, or change it.

Divs and meaning

Because a div means nothing, use it only when no better tag exists. A page header should be a <header>, a navigation menu a <nav>, the main content a <main>, and an article an <article>. These semantic tags (you will learn them in the Semantics lesson) help search engines and screen readers understand your page. Divs fill in the gaps between them.

Tip: A page made only of divs is called "div soup". It works, but it is hard to read and bad for SEO. Use semantic tags for the big sections and divs for the small groups inside them.

Example

Example
<!DOCTYPE html>
<html>
<head>
<title>Div</title>
<style>
.card { border: 1px solid #ccc; padding: 16px; border-radius: 8px; }
</style>
</head>
<body>

<div class="card">
<h2>HTML Course</h2>
<p>Learn HTML from scratch, free.</p>
<button>Start Learning</button>
</div>

</body>
</html>

Output

Output — how it looks in the browser
Output of HTML Div
Try it yourself: copy the code above into a file named test.html, open it in your browser, and change the text to see what happens. That is how you learn — by changing things and watching the result.
Get certified — just ₹10

Finish all 30 lessons, pass the test (80%), pay ₹10 and get your certificate.

Take the test
Go further with a full course

Free tutorials teach you the basics. Our paid courses add live projects, mentorship and a certificate.

CapCut Mobile Video Editing Course Beginner to Advance
₹99
View
Android & iOS App Development using Flutter 2026
₹5,000
View
Website Design Using WordPress 3 Days (Basic to Advanced)
₹199
View
Browse all courses
HTML — Lessons
1. HTML Introduction 2. HTML Editors 3. HTML Basic 4. HTML Elements 5. HTML Attributes 6. HTML Headings 7. HTML Paragraphs 8. HTML Styles 9. HTML Formatting 10. HTML Comments 11. HTML Colors 12. HTML CSS 13. HTML Links 14. HTML Images 15. HTML Favicon 16. HTML Page Title 17. HTML Tables 18. HTML Lists 19. HTML Block and Inline Elements 20. HTML Div 21. HTML Classes 22. HTML Id 23. HTML Iframes 24. HTML JavaScript 25. HTML File Paths 26. HTML Head 27. HTML Layout 28. HTML Responsive 29. HTML Semantics 30. HTML Forms
Final Test — Certificate ₹10

🤖 KAMALDNP AI Assistant

Ask about courses, website & more

Hi! I'm KAMALDNP AI Assistant. Ask me about our courses, website features, or anything else! 😊
Please wait 5s...
🛡️ 7-Day Money-Back Guarantee
🤖 KAMALDNP Assistant ✕

Request human callback:

🔐 Login Required
✕

Download karne ke liye login karo. Login ke baad yahi page pe rahoge!

Naya ho? Register karo →