HTML <img> alignAttribute

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

Example

Set the alignment of an image in text:

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

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the align attribute.


Definition and Usage

HTML5 does not support the <img> align attribute. Use CSS instead.

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

The align attribute specifies the alignment of an image relative to surrounding elements.

The <img> element is an inline element (it does not insert a new line on the page), which means text and other elements can wrap around it. Therefore, the align attribute helps us specify the alignment of the image relative to surrounding elements.


Compatibility Notes

In HTML 4.01, the align attribute of <img> is deprecated. Use CSS instead.

CSS syntax: <img style="float:right">

CSS Example: Float an image to the right

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


Syntax

<img align="left|right|middle|top|bottom">

Attribute Values

Value Description
left Aligns the image to the left.
right Aligns the image to the right.
middle Aligns the image to the center.
top Aligns the image to the top.
bottom Aligns the image to the bottom.


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