HTMLImageElement.align - Web APIs 编辑
Obsolete
This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.
The obsolete align
property of the HTMLImageElement
interface is a string which indicates how to position the image relative to its container. You should instead use the CSS propertiy vertical-align
, which does in fact also work on images despite its name. You can also use the float
property to float the image to the left or right margin.
The align
property reflects the HTML align
content attribute.
Syntax
htmlImageElement.align = alignMode; alignMode = htmlImageElement.align;
Value
A DOMString
specifying one of the following strings which set the alignment mode for the image.
Baseline alignment
These three values specify the alignment of the element relative to the text baseline. These should be replaced by using the CSS vertical-align
property.
bottom
- The bottom edge of the image is to be aligned vertically with the current text baseline. Default value.
middle
- The center of the object should be aligned vertically with the current baseline.
top
- The top edge of the object should be aligned vertically with the current baseline.
It may be worth noting that vertical-align
offers several additional options for its value; you may wish to consider these when changing your code to use it.
Floating images horizontally
The left
and right
properties don't affect the baseline-relative alignment. Instead, they cause the image to "float" to the left or right margin, allowing the following text to flow around the image. You should instead use the CSS float
property, specifying as the value either left
or right
.
left
- Floats the image over to place the left edge flush against the curent margin. Any text that follows will flow against the image's right edge.
right
- Floats the image to place its right edge flush against the right margin. Subsequent text will flow along the image's left edge.
Specifications
Specification | Status | Comment |
---|---|---|
HTML Living Standard The definition of 'HTMLImageElement.align' in that specification. | Living Standard | |
HTML 4.01 Specification The definition of 'HTMLImageElement.align' in that specification. | Recommendation |
Browser compatibility
BCD tables only load in the browser
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论