The valign attribute in the <th> tag is used to specify the vertical alignment of content within a header cell. It was commonly used in older HTML but is now deprecated in HTML5.
- Specifies vertical alignment (e.g., top, middle, bottom, baseline).
- Used only with the <th> element.
- Controls vertical positioning of header content.
Note: The valign attribute is deprecated in HTML5; use CSS (vertical-align) instead.
Syntax
<th valign="top | middle | bottom | baseline">Attribute Value
- top: It sets the table header content to top-align.
- middle: It sets the table header content to middle-align.
- bottom: It sets the table header content to bottom-align.
- baseline: It sets the table header content to baseline. The baseline is the line where most of the characters sit. It is a default value.
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>
<head>
<title>
HTML th valign Attribute
</title>
</head>
<body>
<h1>GeeksforGeeks</h1>
<h2>HTML th valign Attribute</h2>
<!--Driver Code Ends-->
<table border="1" width="500">
<tr style="height:100px;">
<th valign="top">NAME</th>
<th valign="center">AGE</th>
<th valign="bottom">BRANCH</th>
</tr>
<tr>
<td>Ben</td>
<td>22</td>
<td>CSE</td>
</tr>
<tr>
<td>Ron</td>
<td>25</td>
<td>EC</td>
</tr>
</table>
<!--Driver Code Starts-->
</body>
</html>
<!--Driver Code Ends-->