<img id="avatar" src="/shared-assets/images/examples/grapefruit-slice.jpg" />
<pre id="log"></pre>HTMLImageElement: x property / notebook
HTMLImageElement: x property
Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.
img {
margin-left: 30px;
margin-top: 20px;
max-width: 4em;
}const logBox = document.querySelector("pre");
const log = (msg) => {
logBox.innerText += `${msg}\n`;
};
const image = document.getElementById("avatar");
log(`Image's global X: ${image.x}`);
log(`Image's global Y: ${image.y}`);