Open In App

HTML <td> charoff Attribute

Last Updated : 04 Oct, 2024
Comments
Improve
Suggest changes
Like Article
Like
Report

The HTML <td> charoff attribute specifies the offset for aligning text around a specified character within a table cell. It is used with the char attribute and is now considered obsolete in modern HTML. This attribute can only be used in the char attribute and the align attribute is specified in the td element.

Note:  The <td> charoff attribute is not supported by HTML5.  

Syntax

<td charoff="number">

Attribute Values

  • number: It contains the numeric value that specifies the alignment of the td element.
    • Positive values: Indicate the alignment to the right of the characters.
    • Negative values: Indicate the alignment to the left of the characters.

Example: In this example we creates a table using the <td> charoff attribute to align content based on character offset. However, the charoff attribute is now obsolete.

HTML
<!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>
        <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>
    </center>
</body>

</html>

Output:

HTML <td> charoff Attribute” width=”543″ height=”inherit” srcset=”https://media.geeksforgeeks.org/wp-content/uploads/20220203150139/output.png, “><figcaption>HTML  charoff Attribute</figcaption></figure><h3><b><strong>Supported Browsers</strong></b></h3><ul><li value=Google Chrome Not supported
  • Internet Explorer Not supported
  • Firefox Not supported
  • Apple Safari Not supported
  • Opera Not supported


  • Next Article

    Similar Reads