HTML <td> height Attribute

Last Updated : 22 May, 2026

The HTML <td> height attribute is used to specify the height of a table data cell. It defines how tall the cell should appear within a table row.

  • Used inside the <td> tag to set cell height.
  • The height can be given in pixels or percentage.
  • In modern HTML, CSS height property is preferred instead of the height attribute.

Syntax

<td height="pixels | %">
  • pixels: It sets the height of the table cell in terms of pixels.
  • %: It sets the height of the table cell in terms of percentage (%). 

Note: The <td> height Attribute is not supported by HTML.

<td> height Attribute Examples

Example 1: Use of the "height" attribute within table cells (td) to specify their height. Each row contains cells with different heights, affecting the table's overall appearance.

HTML
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>
    <head>
        <title>HTML td height Attribute</title>
    </head>

    <body>
        <h1>GeeksforGeeks</h1>
        <h2>HTML td height Attribute</h2>

<!--Driver Code Ends-->

        <table border="1" width="500">
            <tr>
                <th>NAME</th>
                <th>AGE</th>
                <th>BRANCH</th>
            </tr>

            <tr>
                <td height="50">Ben</td>
                <td height="50">22</td>
                <td height="50">CSE</td>
            </tr>

            <tr>
                <td height="100">Daniel</td>
                <td height="100">25</td>
                <td height="100">EC</td>
            </tr>
        </table>

<!--Driver Code Starts-->
    </body>
</html>

<!--Driver Code Ends-->

Example 2: Demonstrates the usage of the "height" attribute within table cells (td) to specify their height as a percentage of the table row's height, maintaining consistency across cells.

HTML
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>
    <head>
        <title>HTML td height Attribute</title>
    </head>

    <body>
        <h1>GeeksforGeeks</h1>
        <h2>HTML td height Attribute</h2>

<!--Driver Code Ends-->

        <table
            border="1"
            width="500"
            cellspacing="0"
            cellpadding="8"
        >
            <tr>
                <th style="height: 10%">NAME</th>
                <th style="height: 10%">AGE</th>
                <th style="height: 10%">
                    BRANCH
                </th>
            </tr>

            <tr>
                <td style="height: 10%">Ben</td>
                <td style="height: 10%">22</td>
                <td style="height: 10%">CSE</td>
            </tr>
        </table>

<!--Driver Code Starts-->
    </body>
</html>

<!--Driver Code Ends-->
Comment