Skip to main content

Command Palette

Search for a command to run...

HTML Tables (`<table>` Tag)

Updated
2 min read
M
Hi, I'm Subhash Singh, a Computer Science student passionate about web development, programming, and technology. I share simple and beginner-friendly content to help others learn and grow.

Introduction

HTML tables are used to display data in rows and columns. They help organize information neatly and make it easier for users to read. Tables are commonly used for student records, product lists, timetables, and reports.

In this article, you'll learn how to create tables in HTML using simple examples.


What is the <table> Tag?

The <table> tag is used to create a table in HTML.

Example

<table border="1">
  <tr>
    <th>Name</th>
    <th>Age</th>
  </tr>

  <tr>
    <td>Subhash</td>
    <td>20</td>
  </tr>
</table>

Important Table Tags

<table>

Creates the table.

<tr>

Represents a table row.

<th>

Defines a table heading.

<td>

Defines table data (cell).


Output

Name Age
Subhash 20

Why Use Tables?

  • Display structured data
  • Organize information neatly
  • Improve readability
  • Useful for reports and schedules

Best Practices

  • Use <th> for headings.
  • Keep tables simple and readable.
  • Avoid using tables for page layout.
  • Use meaningful column names.

Conclusion

HTML tables are a great way to display structured information. By understanding <table>, <tr>, <th>, and <td>, you can easily create clean and organized tables for your websites.


Frequently Asked Questions (FAQs)

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

The <table> tag.

2. What does <tr> mean?

<tr> stands for Table Row.

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

<th> is used for headings, while <td> is used for normal table data.

4. Can I create tables without borders?

Yes. Borders can be added later using CSS.