Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

HTML DOM Image vspace Property

  • Last Updated : 10 Oct, 2021

The HTML DOM Image vspace Property is used to set or return the value of the vspace attribute of the image element. The vspace attribute is used to specify the number of whitespaces from bottom and top side of an Image.

Syntax

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

It returns the image vspace property.

ImageObject.vspace; 

It sets the image vspace property.



ImageObject.vspace="pixels";

  
 

Property Values: It contains the value i.e. pixels that indicates the number of whitespaces from the bottom and top side of an image. 

 

Example 1: This example returns the vspace property. 

 

HTML




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

Output:

Example2: This example sets the Image vspace property. 

HTML




<!DOCTYPE html>
<html>
 
<body>
    <center>
        <h1 style="color: green">
            GeeksforGeeks
        </h1>
         
        <h2>HTML DOM Image vspace Property</h2>
         
         
<p> <img id="GFG" vspace="20" align="middle"
                alt="GeeksforGeeks logo">
            It is a computer science portal for Geeks.
        </p>
 
        <br>
 
        <button onclick="Geeks()">
            Click me!
        </button>
 
        <p id="sudo"></p>
 
    </center>
     
    <script>
        function Geeks() {
            var g = document.getElementById("GFG").vspace = "5";
            document.getElementById("sudo").innerHTML = g + "px";
        }
    </script>
</body>
 
</html>

Output:

Supported Browsers:

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



My Personal Notes arrow_drop_up
Recommended Articles
Page :