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

HTML Tables

2 min read · Free · No login needed

Tables show data in rows and columns — timetables, price lists, exam schemes, comparison charts. A table is built from four tags: <table> for the whole table, <tr> for each row, <th> for a header cell, and <td> for a normal data cell.

Structure of a table

Every row is a <tr>. Inside a row, you put cells. The first row usually uses <th> (header) cells, which browsers show in bold and centred. All other rows use <td> cells. A table with 3 rows and 3 columns has 3 <tr> elements, each holding 3 cells.

Caption, colspan and rowspan

  • <caption> — a title for the table, placed right after <table>.
  • colspan="2" — a cell that stretches across 2 columns.
  • rowspan="2" — a cell that stretches across 2 rows.

Tables are for data, not layout

In the old days, websites were laid out with tables. Never do that today — use CSS for layout. Tables are only for real tabular data. A table used for layout is hard to make responsive, and screen readers read it out in a confusing order.

Tip: Add a little CSS — borders, padding, and a light background on alternate rows — and even a plain table becomes easy to read. Zebra striping (every second row shaded) helps the eye follow a row across wide tables.

Example

Example
<!DOCTYPE html>
<html>
<head>
<title>Tables</title>
<style>
table, th, td { border: 1px solid #999; border-collapse: collapse; }
th, td { padding: 8px 12px; }
</style>
</head>
<body>

<table>
<caption>Weekly Class Schedule</caption>
<tr><th>Day</th><th>Subject</th><th>Time</th></tr>
<tr><td>Monday</td><td>HTML Basics</td><td>10:00 AM</td></tr>
<tr><td>Tuesday</td><td>CSS Styling</td><td>10:00 AM</td></tr>
</table>

</body>
</html>

Output

Output — how it looks in the browser
Output of HTML Tables
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.

AI Power Skills in 2 Days | Learn AI Text, Image, Video and Voice Tools
View
Advanced Cyber Security Industrial Training
₹5,000
View
CapCut Mobile Video Editing Course Beginner to Advance
₹99
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 →