HTMLImageElement: align property
Deprecated
Avoid using this feature in new projects. This feature may be a candidate for removal from web standards or browsers.>
The deprecated align property of the HTMLImageElement interface is a string which indicates how to position the image relative to its container. It reflects the <img> element's align content attribute.
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.
Value
A string whose value is one of top, middle, bottom, left, or right. For their meanings, see the HTML <img> reference.
Examples
>Setting the align attribute
const img = new Image();
img.src = "example.png";
img.align = "top";
Instead of using the deprecated align property, consider setting the CSS vertical-align property instead:
const img = new Image();
img.src = "example.png";
img.style.verticalAlign = "top";
Specifications
| Specification |
|---|
| HTML> # dom-img-align> |