Skip to content
Related Articles

Related Articles

Improve Article

HTML | DOM Object align Property

  • Last Updated : 11 May, 2021

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

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.
  • 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() {
 
            // Accessing Object element.
            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() {
  
            // Accessing Object element.
            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

Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.




My Personal Notes arrow_drop_up
Recommended Articles
Page :