HTML <td> height Attribute
Last Updated :
11 Mar, 2024
The HTML <td> height Attribute is used to specify the height of the table cell. If the <td> height attribute is not set then it takes the default height according to content.
Note: The <td> height Attribute is not supported by HTML.
Syntax
<td height="pixels | %">
Attribute ValuesÂ
Attribute Values
|
Description
|
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 (%).
|
HTML <td> height Attribute Examples
Example 1:Â This example we 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
<!DOCTYPE html>
< html >
< head >
< title >HTML td height Attribute</ title >
</ head >
< body >
< h1 >GeeksforGeeks</ h1 >
< h2 >HTML td height Attribute</ h2 >
< table border = "1" width = "500" >
< tr >
< th >NAME</ th >
< th >AGE</ th >
< th >BRANCH</ th >
</ tr >
< tr >
< td height = "50" >BITTU</ td >
< td height = "50" >22</ td >
< td height = "50" >CSE</ td >
</ tr >
< tr >
< td height = "100" >RAKESH</ td >
< td height = "100" >25</ td >
< td height = "100" >EC</ td >
</ tr >
</ table >
</ body >
</ html >
|
Output:
 HTML height AttributeÂ
Example 2:Â This example we 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
<!DOCTYPE html>
< html >
< head >
< title >HTML td height Attribute</ title >
</ head >
< body >
< h1 >GeeksforGeeks</ h1 >
< h2 >HTML td height Attribute</ h2 >
< 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%" >BITTU</ td >
< td style = "height: 10%" >22</ td >
< td style = "height: 10%" >CSE</ td >
</ tr >
</ table >
</ body >
</ html >
|
Output:
Supported Browsers
Like Article
Suggest improvement
Share your thoughts in the comments
Please Login to comment...