Latest web development tutorials

HTML img align property

HTML img tag Reference Manual HTML <img> tag

Examples

Set the text of the image is aligned:

<p>这是一些文本。 <img src="smiley.gif" alt="Smiley face" width="42" height="42" align="middle"> 这是一些文本。</p>

try it"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support align attribute.


Definition and Usage

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

In HTML 4.01, <img> The align attribute is deprecated .

align attribute specifies the alignment of the image in relation to surrounding elements.

<Img> element is an inline element (does not insert a new row on the page), which means text and other elements can be around at their surroundings. Therefore, align attributes can help us with respect to a predetermined image alignment of surrounding elements.


Compatibility Notes

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

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

CSS Example: right-floating image

In our CSS tutorial you can find more information about the float property detail.


grammar

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

Property Value

描述
left 把图像对齐到左边。
right 把图像对齐到右边。
middle 把图像与中央对齐。
top 把图像与顶部对齐。
bottom 把图像与底部对齐。


HTML img tag Reference Manual HTML <img> tag