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 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. For the permitted values, see the HTML <img>
reference.
Examples
>Setting the align attribute
const img = new Image();
img.src = "example.png";
img.align = "top";
Instead of doing this, consider:
const img = new Image();
img.src = "example.png";
img.style.verticalAlign = "top";
Specifications
Specification |
---|
HTML> # dom-img-align> |
Browser compatibility
Loading…