Module 9: HTML Tables

Introduction to HTML Tables

HTML tables are used to display data in a tabular format. A table consists of rows, and each row contains cells that can hold data or header information.

The basic structure of a table includes the following tags:

Creating a Simple Table

Example: A basic table with three columns and two rows.


<table border="1">
    <tr>
        <th>Name</th>
        <th>Age</th>
        <th>City</th>
    </tr>
    <tr>
        <td>Alice</td>
        <td>24</td>
        <td>New York</td>
    </tr>
    <tr>
        <td>Bob</td>
        <td>30</td>
        <td>Los Angeles</td>
    </tr>
</table>
            

Try It Yourself

Quiz: Test Your Knowledge

Which HTML element is used to define a table row?

Coding Challenge

Create a table that displays the following information: