HTML <th> charoff Attribute

Last Updated : 22 May, 2026

The charoff attribute of the <th> tag specifies the offset (number of characters) used when aligning content based on a specific character. It works with the char attribute and is now deprecated in HTML5.

  • Defines the offset for alignment relative to a character.
  • Used with char and align="char" attributes.
  • Value is a numeric offset.

Note:  The th charoff attribute is not supported by HTML 5. 

Syntax:

<th charoff="number">

Attribute Values:

  • number: Specifies the numeric offset used for alignment.
  • Positive values: Align content to the right of the specified character.
  • Negative values: Align content to the left of the specified character.

Example: Below HTML code illustrates the use of charoff attribute in <th>.

HTML
<!--Driver Code Starts-->
<!DOCTYPE html>
<html>

<head>
    <title>HTML th charoff attribute  </title>
    <style>
        body {
            text-align: center;
        }
        
        h1,h2 {
            color: green;
        }
        
        th {
            color: blue;
        }
        
        table,
        tbody,
        td {
            border: 1px solid black;
            border-collapse: collapse;
        }
    </style>
</head>

<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <h2> HTML th charoff Attribute</h2>
<!--Driver Code Ends-->

        <table>
            <thead>
                <!-- tr tag starts here -->
                <tr align="char" charoff=".">
                    <th align="char" charoff="." >
                        Country_name
                    </th>
                    <th>Total Medals</th>
                </tr>
            <thead>
            <tbody>
                <tr>
                    <td>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-->
Comment