HTML Table Cells

HTML tables are a great way to display tabular data on a web page. A table is made up of rows and columns, and at the intersection of each row and column is a table cell. Here's a quick guide to understanding table cells in HTML.

Types of Table Cells

Data Cells (<td>):

Used to define standard table cells that hold data. html Copy code

HTMLcopy
<table>
    <tr>
        <td>Apple</td>
        <td>50</td>
    </tr>
</table>


Header Cells (<th>):

Used to define header cells, typically at the top of a column or the start of a row. By default, text inside <th> is bold and centered. html Copy code

HTMLcopy
<table>
    <tr>
        <th>Item</th>
        <th>Quantity</th>
    </tr>
    <tr>
        <td>Apple</td>
        <td>50</td>
    </tr>
</table>


Combining Rows and Columns

Rowspan: A cell can span multiple rows using the <rowspan> attribute.

HTMLcopy
<table>
    <tr>
        <th rowspan="2">Fruit</th>
        <td>Apple</td>
    </tr>
    <tr>
        <td>Banana</td>
    </tr>
</table>

Colspan A cell can span multiple columns using the <colspan> attribute.

HTMLcopy
<table>
    <tr>
        <th colspan="2">Fruits</th>
    </tr>
    <tr>
        <td>Apple</td>
        <td>Banana</td>
    </tr>
</table>



Remember to always use proper semantic tags for better accessibility and readability!

Page 27 of 33

Page 27 of 33

logoFALYTOM

Learn technologies like HTML, CSS, JavaScript, React, NodeJS and so much more. Practice your skills with our free games, examples, practice questions & quizzes

    © 2024 Tomilola Group
    • facebook logo
    • twitter logo
    • instagram logo
    • linkedin logo
    • github logo
    • youtube logo