Logo

Create Tables in HTML : A Beginner’s Guide

Create Tables in HTML : A Beginner’s Guide

Create Table in HTML: A Beginner's Guide

Tables are a fundamental part of web development, providing a structured way to display data. Whether you’re creating a simple list or a complex data grid, HTML tables offer a versatile solution. In this tutorial, we’ll walk through the basics of creating tables in HTML, covering everything from the basic structure to styling tips.

Basic Structure of an HTML Table

An HTML table is defined using the <table> tag. Within the table, rows are created using the <tr> (table row) tag, and within each row, cells are defined using either <td> (table data) or <th> (table header) tags.

Here’s a simple example of a basic HTML table:

				
					<!DOCTYPE html>
<html>
<head>
    <title>HTML Table Example</title>
</head>
<body>
    <h1>Simple HTML Table</h1>
    <table border="1">
        <tr>
            <th>Header 1</th>
            <th>Header 2</th>
            <th>Header 3</th>
        </tr>
        <tr>
            <td>Data 1</td>
            <td>Data 2</td>
            <td>Data 3</td>
        </tr>
        <tr>
            <td>Data 4</td>
            <td>Data 5</td>
            <td>Data 6</td>
        </tr>
    </table>
</body>
</html>

				
			

Breakdown of the Table Structure

  • <table>: This tag defines the table’s start and end.
  • <tr>: This tag defines a row in the table.
  • <th>: This tag defines a header cell in the table. Content in <th> tags is bold and centered by default.
  • <td>: This tag defines a standard cell in the table.

In this example, the border="1" attribute is added to the <table> tag to make the borders visible, helping you see the table’s structure more clearly.

Conclusion :

Creating a basic HTML table is straightforward once you understand the essential tags. Practice building simple tables to get comfortable with the syntax, and you’ll be ready to tackle more complex tables in no time.

Scroll to Top