SA-21/06, C-11, Asapur, Varanasi, UP support@kamaldnp.com +91 8318013442
HTML
1. HTML Introduction: What is HTML? Learn with Examples 2. Best Free HTML Editors: Notepad to VS Code for Beginners 3. HTML Basic Structure: Doctype, Head, Body Explained 4. HTML Elements Explained: Tags, Content & Empty Elements 5. HTML Attributes List: href, src, alt, width, title & More 6. HTML Headings h1 to h6: Which Heading Tag to Use When 7. HTML Paragraphs: p Tag, br Line Breaks & pre Text 8. HTML Style Attribute: Colour, Font Size & Alignment 9. HTML Text Formatting Tags: bold, italic, mark & More 10. HTML Comments: How to Add Notes & Hide Code in HTML 11. HTML Colors: Names, HEX, RGB & HSL Colour Codes 12. HTML CSS: Inline, Internal & External Stylesheets 13. HTML Links: a Tag, href, New Tab & Email Links 14. HTML Images: img Tag, src, alt, Width & Formats 15. HTML Favicon: Create & Add a Browser Tab Icon 16. HTML Title Tag: How to Write a Good Page Title 17. HTML Tables: table, tr, th, td, colspan & rowspan 18. HTML Lists: ul, ol, dl & Nested Lists Explained 19. HTML Block vs Inline Elements: div, p, span Explained 20. HTML Div Tag: Group Content & Build Page Layouts 21. HTML Class Attribute: Style Many Elements at Once 22. HTML id Attribute: Unique IDs, Links, CSS & JavaScript 23. HTML Iframes: Embed YouTube, Maps & Pages in HTML 24. HTML JavaScript: script Tag, Clicks & First Example 25. HTML File Paths: Relative vs Absolute Paths Explained 26. HTML Head Element: title, meta, charset & viewport 27. HTML Layout: header, nav, main, footer Page Structure 28. HTML Responsive Design: Viewport, Images & Media Queries 29. Semantic HTML Tags: header, nav, main, article & footer 30. HTML Forms: input, label, select, checkbox & Submit 31. HTML Entities: & < > © with Examples 32. HTML Audio & Video Tags: controls, source & Fallback 33. HTML Accessibility: alt Text, Labels, Landmarks & ARIA 34. HTML Meta Tags & SEO: charset, viewport, OG Tags 35. HTML Quotations: blockquote, q, cite, abbr & address
Final Test — Certificate ₹10
Try this code live
Lesson 20 of 35

HTML Div Tag: Group Content & Build Page Layouts

3 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.

Diagram — see how it fits together
Infographic: a div box that holds things

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.

What a div is

A <div> is a generic box. It means nothing by itself — it is simply a container you use to group other elements together so you can style them or move them as one unit. A page is mostly divs: a div for the header, a div for the main content, a div for each card. The div itself adds nothing visible; the CSS you attach to it does the work.

Syntax

<div class="card">
  <h2>HTML Course</h2>
  <p>Learn HTML from scratch.</p>
  <a href="course.html">Start learning</a>
</div>

Here the div groups a heading, a paragraph, and a link into one card. With one CSS rule for .card, you can give all three a border, padding, and a background at once.

Note: Because a div means nothing, it tells search engines and screen readers nothing either. If the group has a clear meaning — a header, a navigation menu, a footer — use the matching semantic tag instead: <header>, <nav>, <footer>. Save divs for groups with no better name.
Tip: Give your divs clear class names that describe their job, like class="course-card" or class="sidebar". A class called box1 tells the next person (or you, in three months) nothing.

Common mistakes

  • Using a div for everything — header, nav, and footer have their own tags, so use them.
  • Forgetting to close a div — one missing </div> can shift the whole rest of the page.
  • Nesting divs ten levels deep — if you cannot follow your own nesting, flatten the structure.
  • Styling with <div style="..."> everywhere instead of giving the div a class once.

Example explained

  • .card { border: 1px solid #ccc; padding: 16px; border-radius: 8px; } — one CSS rule that styles every element with class "card": a light border, padding inside, and rounded corners.
  • <div class="card"> — groups the heading, the paragraph, and the button into one box, so the card's border wraps around all three at once.
  • <h2>HTML Course</h2> and <p>Learn HTML from scratch, free.</p> — the content of the card. They belong to the card, so they sit inside the div.
  • <button>Start Learning</button> — the call to action inside the card. It is part of the same group, so it stays inside the same box.

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 Tag: Group Content & Build Page Layouts

Try it yourself — live editor

Change the code below and press Run to see the result instantly. No file to save, no login needed.

Result

Frequently asked questions

The questions learners ask most about this lesson — read the question, then open it to see the answer.

1. What is a div?

It is a generic block-level container with no meaning of its own, used to group elements so you can style or move them as one unit.

2. When should you not use a div?

When a better tag exists, such as header for a page header, nav for navigation, main for main content, or footer for a footer.

3. What is div soup?

A page made only of divs; it works, but it is hard to read and bad for SEO, so use semantic tags for big sections.

Why learn this yourself — and not just ask AI?

AI can write code for you, but it cannot think for you. When you learn HTML yourself, your brain builds the real skill: you understand why a page looks the way it does, you can fix it when it breaks, and you can answer it in an exam or an interview without help. That is the skill that gets you a job — not a copied answer.

Get certified — just ₹10

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

Take the test

Prefer watching? Video courses teach the same topics step by step.

Go further with a full course

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

WordPress Website Development Course (10 Days)
₹399
View
Summer Training in Python Programming 2026
₹3,000
View
Ethical Hacking & Cyber Security Workshop
View
Browse all courses
HTML — Lessons
1. HTML Introduction: What is HTML? Learn with Examples 2. Best Free HTML Editors: Notepad to VS Code for Beginners 3. HTML Basic Structure: Doctype, Head, Body Explained 4. HTML Elements Explained: Tags, Content & Empty Elements 5. HTML Attributes List: href, src, alt, width, title & More 6. HTML Headings h1 to h6: Which Heading Tag to Use When 7. HTML Paragraphs: p Tag, br Line Breaks & pre Text 8. HTML Style Attribute: Colour, Font Size & Alignment 9. HTML Text Formatting Tags: bold, italic, mark & More 10. HTML Comments: How to Add Notes & Hide Code in HTML 11. HTML Colors: Names, HEX, RGB & HSL Colour Codes 12. HTML CSS: Inline, Internal & External Stylesheets 13. HTML Links: a Tag, href, New Tab & Email Links 14. HTML Images: img Tag, src, alt, Width & Formats 15. HTML Favicon: Create & Add a Browser Tab Icon 16. HTML Title Tag: How to Write a Good Page Title 17. HTML Tables: table, tr, th, td, colspan & rowspan 18. HTML Lists: ul, ol, dl & Nested Lists Explained 19. HTML Block vs Inline Elements: div, p, span Explained 20. HTML Div Tag: Group Content & Build Page Layouts 21. HTML Class Attribute: Style Many Elements at Once 22. HTML id Attribute: Unique IDs, Links, CSS & JavaScript 23. HTML Iframes: Embed YouTube, Maps & Pages in HTML 24. HTML JavaScript: script Tag, Clicks & First Example 25. HTML File Paths: Relative vs Absolute Paths Explained 26. HTML Head Element: title, meta, charset & viewport 27. HTML Layout: header, nav, main, footer Page Structure 28. HTML Responsive Design: Viewport, Images & Media Queries 29. Semantic HTML Tags: header, nav, main, article & footer 30. HTML Forms: input, label, select, checkbox & Submit 31. HTML Entities: & < > © with Examples 32. HTML Audio & Video Tags: controls, source & Fallback 33. HTML Accessibility: alt Text, Labels, Landmarks & ARIA 34. HTML Meta Tags & SEO: charset, viewport, OG Tags 35. HTML Quotations: blockquote, q, cite, abbr & address
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...
🤖 KAMALDNP Assistant ✕

Request human callback:

🔐 Login Required
✕

Please log in to download. You will stay on this page after logging in!

New here? Register now →