HTML tables are one of the most essential components in web development. They allow developers to display structured data in a grid layout using rows and columns. Whether creating data reports, dashboards, invoices, pricing charts, comparison tables, or schedules, HTML tables are crucial for both beginners and advanced developers. In this detailed 1500+ word guide, we explore how to create functional HTML tables, table components, table styling, responsive table techniques, accessibility best practices, and multiple working code examples with outputs.
To improve search reach and impressions, this document includes SEO-friendly keywords such as HTML tables tutorial, working table code, table tags in HTML, creating rows and columns, HTML table formatting, responsive tables, table header, table borders, table styling, HTML table examples, table accessibility, rowspan, colspan, advanced table features.
HTML tables are created using the <table> element which contains multiple rows (<tr>) and cells that can be table headers (<th>) or data cells (<td>). Tables help organize information in a structured way and are widely used in admin dashboards, documentation pages, product listings, financial reports, and academic result sheets.
Structure of an HTML Table
The basic structure includes:
Name
Age
Country
John
28
USA
Maria
25
Canada
| Name | Age | Country |
|---|---|---|
| John | 28 | USA |
| Maria | 25 | Canada |
HTML provides many tags and attributes to improve table structure, readability, accessibility, and styling.
Employee Details
Name
Department
Salary
Alice
IT
$5000
Bob
HR
$4500
Data updated monthly
| Name | Department | Salary |
|---|---|---|
| Alice | IT | $5000 |
| Bob | HR | $4500 |
| Data updated monthly | ||
colspan merges cells horizontally, while rowspan merges cells vertically. These properties help create complex layouts like calendars, schedules, and fee structures.
Student Report
Name
Marks
Grade
Rohit
92
A+
| Student Report | ||
|---|---|---|
| Name | Marks | Grade |
| Rohit | 92 | A+ |
Product
Price
Quantity
$20
5
| Product | Price | Quantity |
|---|---|---|
| $20 | 5 |
Item
Price
Pen
$2
| Item | Price |
|---|---|
| Pen | $2 |
ID
Name
Status
1
Arun
Active
2
Neha
Inactive
| ID | Name | Status |
|---|---|---|
| 1 | Arun | Active |
| 2 | Neha | Inactive |
Responsive tables adjust to different screen sizes. On mobile screens, horizontal scrolling is commonly used.
Product
Category
Price
Stock
Laptop
Electronics
$600
20
Chair
Furniture
$80
50
| Product | Category | Price | Stock |
|---|---|---|---|
| Laptop | Electronics | $600 | 20 |
| Chair | Furniture | $80 | 50 |
Use the <link> tag inside the <head> to attach an external CSS file.
Comments in HTML are written between <!-- and -->.
HTML entities are used to display reserved or special characters.
The <iframe> tag embeds another webpage within the current page.
The id attribute uniquely identifies a single HTML element.
Hyperlinks are created using the <a> tag with an href attribute.
Use the <img> tag and specify the image source with the src attribute.
Use the target="_blank" attribute inside the <a> tag.
Copyrights © 2024 letsupdateskills All rights reserved