HTML Tables

Roll up your sleeves and sharpen your minds as we unravel the mysteries of HTML tables, the ultimate blueprint for presenting data in a structured and visually appealing manner.

An HTML Table

The cornerstone elements of an HTML table are:

Without further ado, let's erect a basic table, a bookshelf of sorts. Here's how we'd put that together:

<table>
    <tr>
        <th>Book Title</th>
        <th>Author</th>
        <th>Year Published</th>
    </tr>
    <tr>
        <td>Adventures of Huckleberry Finn</td>
        <td>Mark Twain</td>
        <td>1884</td>
    </tr>
    <tr>
        <td>War and Peace</td>
        <td>Leo Tolstoy</td>
        <td>1869</td>
    </tr>
</table>

There we have it, a minimalist HTML bookshelf! A delightful sight indeed.

Table Attributes

Tables can also have certain attributes that tell the browser how it should be displayed.

Some attributes frequently associated with tables include:

Let's spruce up our table by implementing these attributes.

<table border="1" cellpadding="5" cellspacing="0" width="100%">
    <tr>
        <th>Book Title</th>
        <th>Author</th>
        <th>Year Published</th>
    </tr>
    <tr>
        <td>Adventures of Huckleberry Finn</td>
        <td>Mark Twain</td>
        <td>1884</td>
    </tr>
    <tr>
        <td>War and Peace</td>
        <td>Leo Tolstoy</td>
        <td>1869</td>
    </tr>
</table>

That's how you can display nicely formatted data on your webpage using HTML tables.

Next, we'll delve into HTML Forms, which allow you to capture user input.

Previous Next

Written © 2024 Written Developer Tutorials and Posts.

𝕏