html
  1. html-td-tag

HTML <td> Tag

  • The HTML <td> tag defines a standard table data cell in an HTML table.
  • It is used to contain data within a table row.

Syntax

<table>
  <tr>
    <td>table data</td>
    <td>table data</td>
    <td>table data</td>
  </tr>
</table>

Example

    <table>
        <thead>
            <tr>
                <th>Name</th>
                <th>Age</th>
                <th>Gender</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td>John Doe</td>
                <td>35</td>
                <td>Male</td>
            </tr>
            <tr>
                <td>Jane Smith</td>
                <td>28</td>
                <td>Female</td>
            </tr>
        </tbody>
    </table>
Try Playground

Explanation

The <td> tag is used to define single cell data within a table row. The data in the cell can be text, HTML tags, images, or any other web content. The <td> tag is always nested within a <tr> tag, which defines a table row.

Use

The <td> tag is used to display tabular data in a structured format on a web page. It can be used to create simple or complex tables, such as contact lists, product catalogs, or financial data.

Important Points

  • The <td> tag must be nested in a <tr> tag to create a table cell.
  • Tables can have multiple rows of data, with each row containing one or more <td> elements.
  • The <td> tag attributes include colspan, rowspan, and headers to create complex table layouts.
  • The <td> tag can contain text, images, links, forms, and other HTML elements.

Summary

The HTML <td> tag is a fundamental building block of web tables and is used to create single cells of data within a table row. It is used for displaying a wide variety of information in a structured format on web pages. The <td> tag attributes can be used to create advanced layouts for complex tables, such as merging cells or grouping headers.

Published on: