Go back

HTML Tables

HTML Tables can be used to display data in tabular fashion. In earlier days, HTML tables for used for layout design. But with modern features like flexbox and grid, we don’t use HTML tables for layouts anymore.

Code

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>HTML Tables</title>
</head>
<body>
    <table border="1">
        <thead bgcolor="#999121">
            <tr>
                <th>Name</th>
                <th>Age</th>
                <th>City</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>
                    <h1>Hello</h1>
                </td>
                <td>30</td>
                <td rowspan="2">
                    <table border="1">
                        <tbody>
                            <tr>
                                <td>1</td>
                                <td>2</td>
                                <td>3</td>
                            </tr>
                        </tbody>
                    </table>
                </td>
            </tr>
            <tr>
                <td>Jane Smith</td>
                <td>25</td>
                <!-- <td>Los Angeles</td> -->
            </tr>
            <tr>
                <td>Mike Johnson</td>
                <td>35</td>
                <td>Chicago</td>
            </tr>
        </tbody>
    </table>
</body>
</html>

It is not possible for us to cover all HTML tags in this small time, but please feel free to see - MDN for latest documentation regarding HTML tags.