Open In App

HTML | <img> hspace Attribute

The HTML <img> hspace attribute is used to specify the number of whitespaces on the left and the right side of the image. The hspace attribute is not supported by HTML 5 you can use CSS there.

Syntax:



<img hspace="pixels"> 

Attribute Values:

Example:




<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML <img> hspace Attribute
    </title>
    
    <style>
        
        h1,
        h3 {
            text-align: center;
        }
          
        h4 {
            font-weight: bold;
        }
    </style>
</head>
  
<body>
  
    <h1 style="color:green;"
            GeeksforGeeks 
        </h1>
  
    <h3>HTML Image hspace Attribute</h3>
    <h4>Image without hspace</h4>
    <p><img id="myImage" src=
            alt="Submit"
            width="42" 
            height="42" 
            align="middle" />
      It is a computer science portal for geeks.GeeksforGeeks
    </p>
    <h4>Image with hspace</h4>
    <p><img id="myImage" src=
            alt="Submit" 
            hspace="40" 
            width="42" 
            height="42"
            align="middle" />
      It is a computer science portal for geeks.GeeksforGeeks
    </p>
  
</body>
  
</html>

Output :



Supported Browsers: The browser supported by HTML <img> hspace Attribute are listed below:


Article Tags :