Card: Table

Tables

In the Halls of Tabular Order

In the realm of structured data, you are the Grandmaster of HTML Table Wizardry! Whenever statistics, financial overviews, or comparisons need to be forged into a rigid, disciplined order, nothing beats a good table. Need to present complex information at a glance? Absolutely—tables are unmatched for clarity.

But beware! If you believe tables are fit for layouts or page structures, you’ve likely cursed the flexibility of modern web design. They’re about as adaptable as an ancient cart in a high-speed race. Use them wisely, and your data will shine in all its majestic order—but keep them out of your layouts, or suffer the wrath of the modern web!

Tables in HTML

Structure data clearly – row by row, column by column!

Token: table, tr, th and caption Element

A Simple Table

Presenting data in perfect order

With the HTML elements <table>, <tr>, and <td> at your command, you are the architect of organized data! Rows and columns become your tools to banish chaos and create clarity.

  • table: The sacred beginning — marks the start of your table.
  • caption: Adds a title, imbuing your creation with purpose.
  • tr: Defines a new row, paving the way forward.
  • th: Grants columns a regal header, befitting their importance.
  • td: A humble cell, eagerly waiting to be filled with your data.
<table>
    <caption>Ingredients</caption>
    <tr>
        <th>Unicorn</th>
        <th>Fairy</th>
    </tr>
    <tr>
        <td>Unicorn Hair</td>
        <td>Fairy Dust</td>
    </tr>
</table>
Token: row and colspan Attribute

Merging Cells

Crafting flexible table structures

With the magical spells colspan and rowspan, you can merge HTML table cells across columns and rows, bending tabular space to your will.

  • colspan: Stretches a cell across multiple columns, like a flowing ribbon. Ideal for content that craves extra room.
  • rowspan: Lets a cell span multiple rows, as if gliding effortlessly from one level to the next. A must-have for uniting cells across rows.
<table>
    <tr>
        <th colspan="2">Unicorn</th>
        <th>Fairy</th>
    </tr>
    <tr>
        <td>Unicorn Hair</td>
        <td>Unicorn Fart</td>
        <td>Fairy Dust</td>
    </tr>
</table>
Token: Table Structure

Mastering Table Structure

Clarity from top to bottom

Behold the secret allies of the HTML table:
thead, tbody, and tfoot.
thead: The herald of clarity, introducing headers that illuminate your data.
tbody: The sturdy backbone, organizing the main content with steadfast precision.
tfoot: The triumphant finale, perfect for footnotes or totals, bringing the table to an elegant close.
Together, they keep your data neat, tidy, and gloriously structured!

<table>
    <thead>
        <!-- table content-->
        <tr>
            <td>...</td>
        </tr>
    </thead>
    <tbody>
        <!-- table content-->
    </tbody>
    <tfoot>
        <!-- table content-->
    </tfoot>
</table>
HTML
<table>
    <caption>Recipe for the Healing Potion</caption>
    <thead>
        <tr>
            <th>Ingredient</th>
            <th>Quantity</th>
            <th>Description</th>
        </tr>
    </thead>
    <tbody>
        <tr>
            <td>Moonwort</td>
            <td>3 leaves</td>
            <td>Collect only during full moon</td>
        </tr>
        <tr>
            <td>Glowing Berries</td>
            <td>5 pieces</td>
            <td>Glowing in the dark</td>
        </tr>
        <tr>
            <td colspan="2">Stardust</td>
            <td>A pinch</td>
        </tr>
    </tbody>
    <tfoot>
        <tr>
            <td colspan="3">Mix all ingredients under the moonlight and heat them in the cauldron.</td>
        </tr>
    </tfoot>
</table>
Scroll to Top