HTML <img> hspaceAttribute

HTML img 标签参考手册HTML <img> Tag

Examples

An image with left and right margins of 20 pixels:

<p><img src="smiley.gif.html" alt="Smiley face" width="42" height="42" align="middle" hspace="20">This is some text. This is some text. This is some text.</p>

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the hspace attribute.


Definition and Usage

HTML5 does not support the <img> hspace attribute. Please use CSS instead.

In HTML 4.01, the hspace attribute of <img>is deprecated。

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


Compatibility Notes

In HTML 4.01, the hspace attribute of <img> is deprecated. Please use CSS instead.

CSS Syntax: <img style="margin: 0px 20px">

CSS Example: Image with margins

In our CSS tutorial, you can find more aboutthe margin propertydetails.


Syntax

<img hspace="pixels">

Attribute Values

Value Description
pixels The whitespace on the left and right sides of the image, in pixels.


HTML img 标签参考手册HTML <img> Tag Other Extensions