Open In App

HTML DOM Heading align Property

The HTML DOM Heading align property is used to set or return the horizontal alignment of the <h1>to <h6> element. 

Note: This property is not supported by HTML5.



Syntax:

It is used to return the align property.



HeadingObject.align;

It is used to set the align property.

HeadingObject.align="left | right | center | justify";

Property Values:

Example: Below HTML code returns and sets the Heading to align property. 




<!DOCTYPE html>
<html>
<body>
    <center>
        <h1 style="color:green;">
            GeeksforGeeks
        </h1>
        <h2> DOM Headings align property </h2>
        <h3 id="headingID" align="left">
            A computer science portal for Geeks
        </h3>
        <button onclick="get()">
            return Alignment
        </button>
        <button onclick="set()">
            Set Alignment
        </button>
        <p id="paraID"></p>
 
        <script>
            function get() {
 
                // Return Heading align Property
                var g = document.getElementById(
                    "headingID").align;
 
                document.getElementById(
                    "paraID").innerHTML = g;
            }
 
            function set() {
 
                // Set the Heading align Property
                var k = document.getElementById(
                    "headingID").align = "right";
 
                document.getElementById(
                    "paraID").innerHTML = k;
            }
        </script>
    </center>
</body>
</html>

Output:

Supported Browsers: 


Article Tags :