HTML | DOM Object align Property

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 obkect align property.
    objectobject.align;
  • It sets the object align property.
    objectobject.align="left | right | center"

Property Values:



  • left: It sets the left-align to horizontal line.
  • center: It sets the center-align to horizontal line. It is the default value.
  • right: It sets the right-align to horizontal line.

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

Example 1: This example returns the object align property.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


Output:

  • Before Clicking On Button:
  • After Clicking On Button:

Example 2: This example sets the object align property

filter_none

edit
close

play_arrow

link
brightness_4
code

<!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>

chevron_right


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

full-stack-img




My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.