English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

HTML Tag Directory

HTML: <img> hspace attribute

The hspace attribute specifies the spacing on the left and right sides of the image.

 HTML <img> tag

Online Example

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 ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the hspace attribute.

Definition and Usage

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

Compatibility Notes

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.

Syntax

<img hspace="pixels">

Attribute Value

ValueDescription
pixelsThe blank space on the left and right of the image, in pixels.
 HTML <img> tag