HTMLImageElement: align property
HTML DOM
HTML DOM
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
```js example-bad 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:
```js example-good
const img = new Image();
img.src = "example.png";
img.style.verticalAlign = "top";