Open In App

HTML | <img> hspace Attribute

Improve
Improve
Like Article
Like
Save
Share
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:




<!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:

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


Last Updated : 08 Aug, 2019
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads