Code2night
  • Home
  • Guest Posts
  • Tutorial
  • Languages
    • Angular
    • C
    • C#
    • HTML/CSS
    • Java
    • JavaScript
    • Node.js
    • Python
    • React
    • SQL Server
    • TypeScript
  • Post Blog
  • Tools
    • JSON Beautifier
    • HTML Beautifier
    • XML Beautifier
    • CSS Beautifier
    • JS Beautifier
    • PDF Editor
    • Word Counter
    • Base64 Encode/Decode
    • Diff Checker
    • JSON to CSV
    • Password Generator
  • Register
  • Login
  1. Home
  2. Blogpost

Tables In HTML

Date- Dec 09,2023

3252

Creating tables in HTML is a way to display tabular data in a structured format. HTML provides several elements for building tables, including the <table>, <tr>, <th> and <td> elements. Here's how to create a simple HTML table:

In this example,

<html>

<head>

    <title>HTML Table Example</title>

</head>

<body>

    <h2>Sample Table</h2>

    <table border="1">

        <tr>

            <th>Heading 1</th>

            <th>Heading 2</th>

            <th>Heading 3</th>

        </tr>

        <tr>

            <td>Row 1, Column 1</td>

            <td>Row 1, Column 2</td>

            <td>Row 1, Column 3</td>

        </tr>

        <tr>

            <td>Row 2, Column 1</td>

            <td>Row 2, Column 2</td>

            <td>Row 2, Column 3</td>

        </tr>

        <tr>

            <td>Row 3, Column 1</td>

            <td>Row 3, Column 2</td>

            <td>Row 3, Column 3</td>

        </tr>

    </table>

</body>

</html>


a). The '<table>' element is used to define the table.

b). For viewing purposes, the border="1" parameter creates a border around the table and its cells. It's not recommended for production use; CSS is preferred for styling.

c). The <tr>  elements define table rows. Each '<tr>'  represents a new row in the table.

d). The '<th>'  elements define table headers, which are displayed in bold by default and centered.

e). The '<td>'  elements define table data cells, which contain the actual data.

More rows and columns can be added as needed. You can also use CSS to style the table, change the border style, and format the table according to your design preferences.





Tables in HTML are commonly used to display data in a structured format, such as product listings, schedules, and data summaries. They are an essential part of web development for organizing and presenting tabular data.

Example:-

<html>

<head>

    <title>HTML Table Example</title>

</head>

<body>

    <h2>Example of Table</h2>

    <table border="2" width=50% align=center bgcolor=yellow height=50% border-color=red cellspacing=10 cellpadding=20>

        <tr bgcolor=orange>

            <th>Roll No.</th>

            <th>Name</th>

            <th>Marks</th>

        </tr>

        <tr>

            <td>101</td>

            <td>herry</td>

            <td>546</td>

        </tr>

        <tr>

            <td>102</td>

            <td>robin</td>

            <td>489</td>

        </tr>

        <tr>

            <td>103</td>

            <td bgcolor=red>joy</td>

            <td>800</td>

        </tr>

    </table>

</body>

</html>


Result:-


Table Attribute will be discussed later.


S
Shubham Saini
Programming author at Code2Night — sharing tutorials on ASP.NET, C#, and more.
View all posts →

Comments

Tags

AspNet
C#
programming
AspNet MVC
c programming
AspNet Core
C
software development
tutorial
MVC
memory management
Paypal
coding
coding best practices
data structures
programming tutorial
tutorials
object oriented programming
Slick Slider
StripeNet
Free Download for Youtube Subscribers!

First click on Subscribe Now and then subscribe the channel and come back here.
Then Click on "Verify and Download" button for download link

Subscribe Now | 1760
Download
Support Us....!

Please Subscribe to support us

Thank you for Downloading....!

Please Subscribe to support us

Continue with Downloading
Be a Member
Join Us On Whatsapp Join Us On Facebook
Code2Night

A community platform for sharing programming knowledge, tutorials, and blogs. Learn, write, and grow with developers worldwide.

Panipat, Haryana, India
info@code2night.com
Quick Links
  • Home
  • Blogs
  • Tutorials
  • About Us
  • Contact
  • Privacy Policy
  • Terms & Conditions
  • Guest Posts
Free Dev Tools
  • JSON Beautifier
  • HTML Beautifier
  • CSS Beautifier
  • JS Beautifier
  • Password Generator
  • QR Code Generator
  • Hash Generator
  • Diff Checker
  • Base64 Encode/Decode
  • Word Counter
By Language
  • Angular
  • C
  • C#
  • HTML/CSS
  • Java
  • JavaScript
  • Node.js
  • Python
  • React
  • SQL Server
  • TypeScript
© 2026 Code2Night. All Rights Reserved.
Made with for developers  |  Privacy  ·  Terms
Translate Page