Skip to content
Related Articles
Open in App
Not now

Related Articles

HTML | DOM Object align Property

Improve Article
Save Article
  • Last Updated : 25 Aug, 2022
Improve Article
Save Article

The HTML DOM Object align property is used to set or return the value of the data attribute of an element.

Note: This property is not supported by HTML5

Syntax: 

  • It returns the object align property.
objectobject.align;
  • It sets the object to align property.
objectobject.align="left | right | middle | top | bottom"

Property Values:

  • left: It sets the object to the left-align. It has a default value.
  • right: It sets the object to the right align.
  • middle: It sets the object to the middle.
  • top: It sets the object to the top-align.
  • bottom: It sets the object to the bottom align.

Return Values: It returns a string value that represents the alignment of the object element. 

Example 1: This example returns the object align property.

HTML




<!DOCTYPE html>
<html>
<head>
    <title>
        HTML DOM Object align Property
    </title>
</head>
<body>
    <object id="myobject" data="HelloGeeks.swf"
        width="400" height="100" align ="center"
        form="myGeeks" data=
    </object>
    <br><br><br>
    <h2 align ="left">DOM Object align Property</h2>
    <button onclick="Geeks()">
        Click it
    </button>
    <p id="gfg" style=
        "color:green; font-size:25px;">
    </p>
 
    <script>
        function Geeks() {
 
            // Return Object align Property
            var x =
                document.getElementById(
                    "myobject").align;
 
            document.getElementById(
                "gfg").innerHTML = x;
        }
    </script>
</body>
</html>

Output: 

  • Before Clicking On Button: 

  • After Clicking On Button: 

Example 2: This example sets the object to align property 

HTML




<!DOCTYPE html>
<html>
<head>
    <title>
        HTML DOM Object align Property
    </title>
</head>
<body>
    <object id="myobject" data="HelloGeeks.swf"
        width="400" height="100" align ="center"
        form="myGeeks" data=
    </object>
    <br><br><br>
    <h2 align ="left">DOM Object align Property</h2>
    <button onclick="Geeks()">
        Click it
    </button>
    <p id="gfg" style=
        "color:green; font-size:25px;">
    </p>
 
    <script>
        function Geeks() {
  
            // set Object align Property
            var x = document.getElementById(
                    "myobject").align = "left";
  
            document.getElementById(
                    "gfg").innerHTML = x;
        }
    </script>
</body>
</html>

Output: 

  • Before Clicking On Button: 

  • After Clicking On Button: 

Supported Browsers: The browsers supported by DOM Object align Property are listed below: 

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

My Personal Notes arrow_drop_up
Related Articles

Start Your Coding Journey Now!