Steps on how to create a table using HTML

0
729

Creating a table in HTML involves using the <table> element along with other related elements like <tr> for table rows, <th> for table headers, and <td> for table data cells. Here's an example of how to create a simple table:

Basic Structure

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML Table Example</title>
    <style>
        table {
            width: 50%;
            border-collapse: collapse;
            margin: 20px auto;
            font-family: Arial, sans-serif;
        }
        th, td {
            border: 1px solid #ddd;
            padding: 8px;
            text-align: center;
        }
        th {
            background-color: #f4f4f4;
        }
    </style>
</head>
<body>
    <h1 style="text-align: center;">HTML Table Example</h1>
    <table>
        <thead>
            <tr>
                <th>Header 1</th>
                <th>Header 2</th>
                <th>Header 3</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>Row 1, Cell 1</td>
                <td>Row 1, Cell 2</td>
                <td>Row 1, Cell 3</td>
            </tr>
            <tr>
                <td>Row 2, Cell 1</td>
                <td>Row 2, Cell 2</td>
                <td>Row 2, Cell 3</td>
            </tr>
            <tr>
                <td>Row 3, Cell 1</td>
                <td>Row 3, Cell 2</td>
                <td>Row 3, Cell 3</td>
            </tr>
        </tbody>
    </table>
</body>
</html>

Explanation

  1. <table>: The container for the entire table.
  2. <thead>: Contains the table header rows.
  3. <th>: Defines a header cell, typically bold and centered.
  4. <tbody>: Contains the main content of the table.
  5. <tr>: Defines a single row in the table.
  6. <td>: Defines a single data cell.

Styling

You can style your table with CSS, as shown in the example. This includes adding borders, padding, and background colors for a cleaner look.

Let me know if you'd like additional features like merged cells, captions, or advanced styling!

Search
Sellect from all Categories bellow ⇓
Read More
HTML
How To Create a Responsive iFrame In HTML
Advanced usage of HTML <iframe> involves...
By flowisetech 2025-02-26 13:06:54 0 395
Blogging
Content Marketing: How to Write Blogs That Drive Traffic
Content marketing is a powerful strategy for...
By Nicholas 2025-03-14 13:17:58 0 852
Blockchain & Cryptocurrencies
How Do Cryptocurrencies Work? A Step-by-Step Explanation
Here’s a detailed explanation of How...
By flowisetech 2025-03-10 12:58:54 0 675
Search Engine Optimization (SEO)
Why Your Newport Business Deserves the Best SEO Agency
When you picture Newport, you might think of...
By markgriffin 2025-02-27 14:02:33 0 444
Ethical Hacking
The Difference Between Black Hat, White Hat, and Gray Hat Hackers
Hackers are individuals who explore and...
By flowisetech 2025-02-24 16:22:33 0 331