HTMLImageElement: align property

Deprecated: This feature is no longer recommended. Though some browsers might still support it, it may have already been removed from the relevant web standards, may be in the process of being dropped, or may only be kept for compatibility purposes. Avoid using it, and update existing code if possible; see the compatibility table at the bottom of this page to guide your decision. Be aware that this feature may cease to work at any time.

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 property 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.

Value

A string 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 current margin. Any text that follows will flow against the image's right edge.

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
HTML Standard
# dom-img-align

Browser compatibility

BCD tables only load in the browser