English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The hspace attribute specifies the spacing on the left and right sides of the image.
Left and right margins are 40 pixel image:
!DOCTYPE html <html> <head> <title>HTML: <img> hspace attribute - Basic Tutorial Website oldtoolbag.com</title> <body> <h4>Image without hspace:/h4> <p><img src="haha.gif" alt="haha face" width="42" height="42" align="middle"> This is some text. This is some text. This is some text./p> <h4>Image has hspace:/h4> <p><img src="haha.gif" alt="haha face" width="42" height="42" align="middle" hspace="40">This is some text. This is some text. This is some text./p> </body> </html>Test and See ‹/›
IEFirefoxOperaChromeSafari
All major browsers support the hspace attribute.
HTML5 The <img> hspace attribute is not supported. Please use CSS instead.
In HTML 4.01 In this example, the hspace attribute of <img> is deprecated.
The hspace attribute specifies the blank space on the left and right of the image
In HTML 4.01 In this example, the hspace attribute of <img> is deprecated. Please use CSS instead.
CSS Syntax: <img style="margin: 0px 20px">
CSS Example: Image with Margin
In our CSS tutorial, you can find more about margin property. Details.
<img hspace="pixels">
Value | Description |
---|---|
pixels | The blank space on the left and right of the image, in pixels. |