Open In App

Output:

Example 2: Below code illustrates how to set the TableHeader align property.

HTML




<!DOCTYPE html>
<html>
<head>
    <!-- Style to set border -->
    <style>
        table,
        th,
        td {
            border: 1px solid black;
        }
    </style>
</head>
<body>
    <center>
        <h1>GeeksforGeeks</h1>
        <h2>
            DOM TableHeader align Property
        </h2>
        <table>
            <tr>
                <th id="table"
                    style="padding:15px" align="left">
                    Username
                </th>
            </tr>
            <tr>
                <td>Manas Chhabra</td>
            </tr>
        </table>
        <br>
        <button onclick="click1()">
            Click Here!
        </button>
        <p id="paraID" style=
            "font-size:25px;color:green">
        </p>
 
    </center>
 
    <!-- script to set the Table Header align Property -->
    <script>
        function click1() {
            var tab = document.getElementById(
                    "table").align = "right";
 
            document.getElementById("sudo")
                .innerHTML = tab;
        }
    </script>
</body>
</html>


Output: 

Supported Browsers:



Like Article
Suggest improvement
Next
Share your thoughts in the comments

Similar Reads

HTML DOM Table Header vAlign Property
How to define whether a header cell is a header for a column, row, or group of columns or rows in HTML 5?
Difference between align-content and align-items
HTML DOM Legend align Property
HTML | DOM HR align Property
HTML DOM THead align Property
HTML | DOM TableRow align Property
HTML | DOM Object align Property
HTML | DOM Paragraph align Property
HTML | DOM Div align Property