HTML img hspace Attribute
HTML <img> tag
Definition and Usage
The hspace attribute specifies a whitespace margin on the left and right of the
image.
Compatibility Notes
The hspace attribute of the img element was deprecated in HTML 4.01
and is not supported in XHTML 1.0 Strict DTD.
Use CSS instead.
CSS syntax: <img style="margin: 0px 20px"/>
In our CSS tutorial you can find more details about the
margin property.
Syntax
Syntax Example
Attribute Values
Value |
Description |
pixels |
Specifies the left and right whitespace margin of the
image in pixels. Note: You cannot set a different value for left and
right whitespace margin with this attribute. |
Browser Support
The attribute is deprecated, but still supported in all major browsers.
Example
Source |
Output |
<img src="demo_img.jpg"
alt="W3Schools example picture"
hspace="20" />
|
|
Try-It-Yourself Demos
img hspace
attribute example
Specify the left and right margin of the image.
In CSS:
image margin example
Specify the left and right margin of the image with CSS.
HTML <img> tag
|