The charoff attribute in the <td> tag was used to set the offset position for aligning content relative to a specific character (defined by the char attribute) within a table cell.
- Specifies the number of characters to offset the alignment.
- Works together with the char attribute.
- Helps control precise alignment of cell content.
- Used mainly for tabular data formatting.
Note: The charoff attribute is obsolete in HTML5 and is no longer supported.
Syntax
<td charoff="number">Attribute Values
- number: Specifies a numeric value for alignment offset.
- Positive values: Align content to the right of the specified character.
- Negative values: Align content to the left of the specified character.
Example: Create a table using the <td> charoff attribute to align content based on character offset. However, the charoff attribute is now obsolete.
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>
<head>
<title>HTML td charoff attribute </title>
<style>
body {
text-align: center;
}
h1 {
color: green;
}
th {
color: blue;
}
table,
tbody,
td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
</head>
<body>
<center>
<h1>GeeksforGeeks</h1>
<h2> HTML td charoff Attribute</h2>
<!--Driver Code Ends-->
<table>
<thead>
<!-- tr tag starts here -->
<tr align="char" charoff=".">
<th>Country_name</th>
<th>Ranking</th>
</tr>
<thead>
<tbody>
<tr>
<td align="char" charoff=".">
China</td>
<td>34</td>
</tr>
<tr>
<td>India</td>
<td>45</td>
</tr>
</tbody>
</table>
<!--Driver Code Starts-->
</center>
</body>
</html>
<!--Driver Code Ends-->