Basic Syntax of HTML Table

<table>
    <tr>
        <th></th>
        <th></th>
        ...
    </tr>
    <tr>
        <td></td>
        <td></td>
        ...
    </tr>
    ...
</table>

Example: Here is an example of HTML table with two rows and three columns.

HTML
<!DOCTYPE html>
<html lang="en">

<head>
    <title>Basic HTML Table</title>
</head>

<body>
    <table border="1">
        <tr>
            <td>Row 1, Column 1</td>
            <td>Row 1, Column 2</td>
        </tr>
        <tr>
            <td>Row 2, Column 1</td>
            <td>Row 2, Column 2</td>
        </tr>
        <tr>
            <td>Row 3, Column 1</td>
            <td>Row 3, Column 2</td>
        </tr>
    </table>
</body>

</html>

Note: The border attribute is not supported by HTML5. CSS border property is used to set the table border in HTML5.

Output:

How to Create Table in HTML?

HTML tables are essential for organizing and displaying data in a structured format on web pages. Creating a table in HTML is a fundamental skill for web developers. It is used for product information, presenting data analytics, or designing a pricing comparison chart, etc. This article provides a step-by-step guide on how to create tables in HTML.

Table of Content

  • Elements of HTML Table
  • Table Structure
  • Basic Syntax of HTML Table
  • Adding Table Heading to Rows
  • HTML Table with thead, tbody, and tfoot Elements

Similar Reads

Elements of HTML Table

Table Elements Description

The
element defines the start and end of the table. It acts as a container for all the table-related elements. The (table row) element defines a row within the table. Each tag represents a horizontal row of cells or data entries. ). Header cells are typically used to label columns or rows in the table. They are usually bold and centered by default, providing emphasis on the content they represent. ). Data cells contain actual data or information that is displayed in the table. Unlike The element defines the header section of a table, containing header rows ( with The element groups the main content of the table, containing rows () with data cells ( The element defines the footer section of a table, usually containing summary rows or totals. and The element allows you to group together and style columns in a table. Inside , you can use elements to define specific column properties such as width, alignment, and styling. This provides more control over the appearance of columns across the table.
The (table header) element defines header cells within a table row (
The (table data) element defines regular data cells within a table row (
cells, cells are not bold and are aligned to the left by default.
).
).
The element provides a title or description for the entire table. It is placed immediately after the opening tag and before any elements....

Table Structure

Within the

element, the table structure is organized as rows () and columns defined by header cells () contain one or more cells ( element. This is useful when you have data that represents headings for each row....

HTML Table with thead, tbody, and tfoot Elements

The

section is used for headers that describe the columns of the table. The section contains the main data rows. The section provides a footer row typically used for summary information or totals....

) or data cells (). Rows (
or ), depending on the structure of the table....

Basic Syntax of HTML Table

... ... ...
...

Adding Table Heading to Rows

To add a table heading to rows in an HTML table, you can use the

element within the