The valign attribute is used to specify the vertical alignment of content within table cells or rows. It was commonly used in older HTML versions but is now deprecated in HTML5.
- Specifies vertical alignment (e.g., top, middle, bottom).
- Used with <td>, <th>, and <tr> elements.
- Helps control vertical positioning of content within cells.
Note: The valign attribute is not supported by HTML5.
Syntax
<element valign="top | middle | bottom | baseline">Attribute value
- top: Aligns content to the top.
- middle: Aligns content to the middle.
- bottom: Aligns content to the bottom.
- baseline: Aligns content to the baseline (the line where most characters sit).
Example: This example illustrates the use of valign attribute in the HTML document.
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>
<head>
<title>
HTML valign Attribute in <td> element
</title>
</head>
<body>
<h1>GeeksforGeeks</h1>
<h2>HTML valign Attribute in Table Data Element</h2>
<!--Driver Code Ends-->
<table border="1" width="500">
<tr>
<th>NAME</th>
<th>ID</th>
<th>AGE</th>
</tr>
<tr style="height:50px;">
<td valign="top">BITTU</td>
<td valign="center">123</td>
<td valign="bottom">21</td>
</tr>
<tr style="height:50px;">
<td valign="bottom">RAKESH</td>
<td valign="center">124</td>
<td valign="top">24</td>
</tr>
</table>
<!--Driver Code Starts-->
</body>
</html>
<!--Driver Code Ends-->