Open In App

HTML DOM Iframe align Property

Last Updated : 06 Jan, 2022
Improve
Improve
Like Article
Like
Save
Share
Report

The HTML Iframe align property is used to set or return the value of the align attribute of the <iframe> element. 

Note: This property is not supported by HTML5.

Syntax:  

It returns the aligned property.

iframeobject.align;

It sets the aligned property.

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

 

Property Values:

  • left: It sets the frame to the left alignment.
  • right: It sets the frame to the right alignment.
  • middle: It sets the frame to the middle.
  • top: It sets the frame to the top alignment.
  • bottom: It sets the frame to the bottom alignment.

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

 Example 1: Below example illustrates how to return the Iframe align property.

HTML




<!DOCTYPE html>
<html>
  
<body style="text-align:center;">
  
    <h1>GeeksforGeeks</h1>
  
    <h2>
        HTML DOM iframe align Property
    </h2>
  
        id="iframeID" align="middle" 
        height="200" width="400">
    </iframe><br>
  
    <button onclick="click1()">Submit</button>
    <p id="paraID"></p>
  
      
    <script>
        function click1() {
            var x = document.getElementById("iframeID").align;
            document.getElementById("paraID").innerHTML = x;
        }
    </script>
</body>
  
</html>


Output:

Example 2: Below example sets the iframe alignment property to right. 

HTML




<!DOCTYPE html>
<html>
  
<body style="text-align:center;">
  
    <h1>GeeksforGeeks</h1>
  
    <h2>
        HTML DOM iframe align Property
    </h2>
  
        id="iframeID" align="middle" 
        height="200" width="400">
    </iframe><br>
  
    <button onclick="click1()">Submit</button>
    <p id="paraID"></p>
  
  
    <script>
        function click1() {
            var x = document.getElementById(
                    "iframeID").align = "right";
                      
            document.getElementById("paraID").innerHTML = x;
        }
    </script>
</body>
  
</html>


Output:

List of Supported Browsers:

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


Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads