HTML Tables Basics: Table Tags, Attributes, Examples & Uses for Beginners 2026

Author: Ritika
0

 

When we start learning HTML in college most of us first create simple webpages like a profile page, college timetableor marks list. I still remember in my second year when our lab teacher asked us to create a student marks table using HTML. At that time, many students in my class got confused about table tags like <tr>, <td>, and <th>.

 

But honestly once you understand the basic structure, HTML tables are very easy.

 

In simple words, HTML tables are used to display data in rows and columnsjust like we see in Excel sheets or exam result tables.

 

In this blog I will explain HTML tables in a simple way like one B.Tech student explaining to another. If you are a beginner this will help you understand the topic clearly for assignments, exams and practice projects.

HTML Tables Basics: Table Tags, Attributes, Examples & Uses for Beginners 2026
(toc) #title=(Table of Content)

 

Introduction to HTML Tables

Basically an HTML table is used to organize data into rows and columns.

 

For example, in college we often see tables like:

  • Student marks list
  • Class timetable
  • Attendance sheet
  • Lab experiment marks
  • Placement records

 

All these can be easily displayed using HTML tables.

 

A table mainly contains:

  • Rows → horizontal data
  • Columns → vertical data
  • Cells → where actual data is written

 

So if we imagine a student marks table each row represents a student and each column represents subjects.

 

When I first learned tables I used them to create a semester result page in HTML. It looked simple but helped me understand how web pages display structured data.

 

Table Tags in HTML

HTML tables are created using different tags. Each tag has its own role. Many students get confused here, but if we go step by step it becomes simple.

 

1. <table> Tag

This is the main tag used to create a table.

Everything related to the table must be written inside this tag.

 


<table></table>

Basically it tells the browser that a table starts here.

 

2. <tr> Tag (Table Row)

The <tr> tag is used to create a row inside the table.

For example if your table has 5 students you will have 5 rows.

 

<tr></tr>

 

Each <tr> represents one horizontal row of data.

 

3. <td> Tag (Table Data)

The <td> tag is used to insert actual data inside the table cell.

 

<td>Ankit</td>
<td>85</td>
<td>90</td>

In simple words, whatever we write inside <td> will appear in the table cell.

 

4. <th> Tag (Table Heading)

The <th> tag is used to create table headings.

Headings are usually written in the first row of the table.

 


<th>Name</th>
<th>Maths</th>
<th>Science</th>

By default <th> text appears bold and centered.

 

Quick Difference Between Tags

Tag Meaning Purpose
<table> Table container Creates the table
<tr> Table row Creates rows
<td> Table data Inserts normal data
<th> Table heading Creates heading cells

 

Many beginners mix up <td> and <th>. Just remember:

  • <th> → headings
  • <td> → data

 

Table Attributes in HTML

Attributes are used to customize or style the table.

Earlier HTML used many attributes for styling. Nowadays we mostly use CSS but for beginners and exams these attributes are still important.

 

Let’s look at some common ones.

 

Border Attribute

This attribute adds a border around the table.

 


<table border="1">

 

If you write border="1" then the table will show visible lines.

Without border the table structure is there but it may not be visible clearly.

 

When I was practicing HTML first time I forgot the border attribute and thought my table was not working. Actually the border was just invisible.

 

Cellpadding Attribute

This attribute controls space inside the cell.

 

<table cellpadding="10">

 

This creates space between cell border and text.

It makes the table look cleaner.

 

Cellspacing Attribute

This attribute controls space between cells.

 

<table cellspacing="5">

 

This adds spacing between each table cell.

 

Width Attribute

This attribute defines the width of the table.

 

<table width="500">

 

You can also use percentage like:

<table width="100%">

 

Align Attribute

This attribute controls alignment of the table.

 


<table align="center">

 

This will place the table in the center of the webpage.

 

Example of HTML Table

Now let’s see a simple student marks table example.

<!DOCTYPE html>
<html>
<head>
<title>Student Marks</title>
</head>

<body>

<h2>Student Marks Table</h2>

<table border="1" cellpadding="10">

<tr>
<th>Name</th>
<th>Maths</th>
<th>Science</th>
<th>English</th>
</tr>

<tr>
<td>Ankit</td>
<td>85</td>
<td>90</td>
<td>88</td>
</tr>

<tr>
<td>Rahul</td>
<td>78</td>
<td>82</td>
<td>80</td>
</tr>

<tr>
<td>Pooja</td>
<td>92</td>
<td>89</td>
<td>95</td>
</tr>

</table>

</body>
</html>

 

Output will show a simple marks table.

This type of example is very common in:

  • HTML lab exams
  • Assignments
  • Practical practice

 

Many teachers ask students to create a student result table using HTMLso practicing this example is very useful.

 

Real Life Use Cases of HTML Tables

Many beginners think tables are only for assignments but actually tables are used in many real websites.

 

Let’s look at some real world uses.

 

College Timetable

Every college has a class schedule.

Day Subject Time
Monday Data Structures 10 AM
Tuesday DBMS 11 AM

 

This is easily created using HTML tables.

 

Student Marks List

Schools and colleges display exam results in tables.

Example columns:

  • Student Name
  • Roll Number
  • Subject Marks
  • Total Marks

 

Product Comparison Tables

E commerce websites use tables to compare products.

Feature Laptop A Laptop B
RAM 8GB 16GB
Price 50,000 70,000

 

This helps users quickly compare features.

 

Placement Records

In many college websites placement data is shown like:

Student Name Company Package
Amit TCS 4 LPA
Neha Infosys 3.6 LPA

 

Tables make the data clear and organized.

 

Database Data Display

In many web applications, data from databases is displayed in table format.

For example:

  • Employee management systems
  • Library systems
  • Online dashboards

 

In my own Employee Management System project I used tables to display employee details like ID, Name, Department and Salary.

 

Common Mistakes Beginners Make

When students first learn tables they often make small mistakes.

 

Here are some common ones:

1. Forgetting <tr> Tag

Some students directly write <td> without a row.

But <td> must always be inside <tr>.

 

2. Missing Closing Tags

Example mistake:


<td>Maths

Correct way:


<td>Maths</td>

 

3. Unequal Number of Cells

If one row has 3 cells and another has 4 the table layout may break.

So always keep the structure consistent.

 

FAQs About HTML Tables

1. What is an HTML table?

An HTML table is used to display data in rows and columns on a webpage. It helps organize information clearly and neatly.

2. Which tag is used to create a table in HTML?

The <table> tag is used to create an HTML table. All table content must be written inside this tag.

3. What is the difference between <td> and <th>?

<td> is used for normal data cells.

<th> is used for table headings and appears bold by default.

4. Why are HTML tables used?

HTML tables are used to display structured data like:

  • marks list
  • timetables
  • product comparison
  • database records
5. Are HTML tables still used today?

Yes, but mostly for data display only. For webpage layout, developers now prefer CSS and modern design techniques.

 

Conclusion

HTML tables are one of the basic and important topics in HTML, especially for beginners and students learning web development.

 

In simple way we can say that tables help us organize data in rows and columns just like we see in Excel sheets or college result lists.

 

We learned:

  • What HTML tables are
  • Important table tags like <table>, <tr>, <td> and <th>
  • Common table attributes
  • Practical examples
  • Real-world use cases

 

When I first practiced HTML tables during my college labs I realized that understanding the structure of rows and columns is the key. Once that becomes clear creating tables becomes very easy.

 

If you are preparing for HTML exams, assignments and small web projectsthen practicing table examples like marks list, time table and comparison tables will help you a lot.

 

My small suggestion for beginners is simple: Open VS Code write a few table examples, and experiment with rows, columns and attributes. Within a short time you will become comfortable with HTML tables.

 

And trust me once the basics are clear web development becomes much more fun to learn.

Tags

Post a Comment

0Comments
Post a Comment (0)

#buttons=(Accept !)#days=(20)

We use cookies to personalize content and ads, provide social media features, and analyze our traffic. By clicking "Accept", you consent to our use of cookies. Privacy Policy Cookies Policy
Accept !
Breaking News | News |