Open In App

HTML DOM Image align Property

The HTML DOM Image align Property is used to set or return the value of the align attribute of the image element. 

Note: This property is no longer supported in HTML5.



Syntax:  

It returns the image align property.



Imageobject.align;

It sets the image to align property.

Imageobject.align="left|right|middle|top|bottom"

  
 

Property Values: 

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

Example 1: This example returns the Image align property. 




<!DOCTYPE html>
<html>
 
<body>
    <center>
        <h1 style="color: green">
            GeeksforGeeks
        </h1>
         
        <h2>HTML DOM Image align Property</h2>
 
        <img id="GFG" align="middle" src=
            alt="GeeksforGeeks logo">
        <br>
        <button onclick="Geeks()">
            Click me!
        </button>
         
        <p id="sudo"></p>
 
 
    </center>
 
    <script>
        function Geeks() {
            var g = document.getElementById("GFG").align;
            document.getElementById("sudo").innerHTML = g;
        }
    </script>
</body>
 
</html>

Output:

Example 2: Below code returns the Image align Property. 




<!DOCTYPE html>
<html>
 
<body>
    <center>
        <h1 style="color: green">
            GeeksforGeeks
        </h1>
         
        <h2>HTML DOM Image align Property</h2>
         
        <img id="GFG" align="middle" src=
            alt="GeeksforGeeks logo">
        <br>
         
        <button onclick="Geeks()">Click me!</button>
         
        <p id="sudo"></p>
 
 
    </center>
 
    <script>
        function Geeks() {
            var g = document.getElementById("GFG").align = "left";
            document.getElementById("sudo").innerHTML = g;
        }
    </script>
</body>
 
</html>

Output:

Supported Browsers:


Article Tags :