Open In App

HTML | <img> hspace Attribute

Last Updated : 08 Aug, 2019
Comments
Improve
Suggest changes
Like Article
Like
Report
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:
  • pixels: It specifies the number of whitespaces in terms of pixels.
Example: html
<!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=
"https://media.geeksforgeeks.org/wp-content/uploads/gfg-40.png" 
            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=
"https://media.geeksforgeeks.org/wp-content/uploads/gfg-40.png" 
            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:
  • Google Chrome
  • Internet Explorer
  • Firefox
  • Opera
  • Safari

Next Article

Similar Reads