Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML DOM Heading align Property

  • Last Updated : 25 Feb, 2022

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.


It is used to return the align property.



It is used to set the align property.

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

Property Values:

  • left: It sets the text left-aligned. It is the default value.
  • right: It sets the text right-aligned.
  • center: It sets the text center-aligned.
  • justify: It stretches the text of the paragraph to set the width of all lines equal.

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


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


Supported Browsers: 

  • Google Chrome
  • Internet Explorer
  • Opera
  • Apple Safari
  • Firefox

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!