files/en-us/web/api/htmlimageelement/align/index.md
{{APIRef("HTML DOM")}}{{deprecated_header}}
The deprecated align property of the {{domxref("HTMLImageElement")}} interface is a string which indicates how to position the image relative to its container. It reflects the `` element's align content attribute.
You should instead use the CSS property {{cssxref("vertical-align")}}, which does in fact also work on images despite its name. You can also use the {{cssxref("float")}} property to float the image to the left or right margin.
A string whose value is one of top, middle, bottom, left, or right. For their meanings, see the HTML `` reference.
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}}
{{Compat}}