HTML Tables are one of the most useful features of HTML for displaying structured information on a webpage. Whether you want to show student details, course information, pricing, schedules, marks, or product data, HTML tables help organize information into rows and columns.
In this guide, you will learn how to create tables in HTML, understand important HTML table tags, and explore practical examples.
What Is an HTML Table?
An HTML table is used to display data in a structured format using rows and columns.
For example:
| Student Name | Course | City |
|---|---|---|
| Mahaveer | Web Designing | Jaipur |
| Rahul | HTML & CSS | Jaipur |
| Priya | Web Development | Jaipur |
To create a table like this, HTML provides several important tags.
Basic HTML Table Tags
The main tags used to create an HTML table are:
| Tag | Purpose |
|---|---|
<table> | Creates the complete table |
<tr> | Creates a table row |
<th> | Creates a table heading |
<td> | Creates a table data cell |
Let’s understand each tag.
1. The <table> Tag
The <table> tag is used to create the main table container.
Example:
All rows, headings, and data cells are placed inside the <table> tag.
2. The <tr> Tag – Table Row
The <tr> tag stands for Table Row.
Each <tr> creates a new row inside the table.
Example:
You can create multiple rows by using multiple <tr> tags.
3. The <th> Tag – Table Heading
The <th> tag stands for Table Header.
It is generally used for column headings.
Example:
The browser usually displays table headings in bold text and centers them by default.
4. The <td> Tag – Table Data
The <td> tag is used to add actual data inside a table.
Example:
Creating Your First HTML Table
Now let’s combine everything together.
Output
| Student Name | Course | City |
|---|---|---|
| Mahaveer | Web Designing | Jaipur |
| Rahul | HTML & CSS | Jaipur |
| Priya | Web Development | Jaipur |
Understanding colspan in HTML Tables
The colspan attribute allows a table cell to occupy multiple columns.
For example:
Here:
means the heading Student Information will cover three columns.
Understanding rowspan in HTML Tables
The rowspan attribute allows a table cell to occupy multiple rows.
Example:
In this example, the name Mahaveer occupies two rows.
Adding Borders to HTML Tables
A simple method for beginners is:
However, in modern web development, CSS is preferred for styling tables.
Example:
Then create your table normally:
Complete HTML Table Example with CSS
Here is a practical example:
Common HTML Table Attributes
Here are some important attributes beginners should understand:
| Attribute | Purpose |
|---|---|
colspan | Combines multiple columns |
rowspan | Combines multiple rows |
border | Adds a basic border |
width | Sets the table width |
cellpadding | Older method for cell spacing |
cellspacing | Older method for space between cells |
For modern websites, CSS should be used instead of older HTML styling attributes whenever possible.








