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:



  • pixels: It specifies the number of whitespaces in terms of pixels.

Example:

filter_none

edit
close

play_arrow

link
brightness_4
code

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

chevron_right


Output :

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

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


My Personal Notes arrow_drop_up


If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :
Practice Tags :


Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.