<div id="mouse"></div>
#mouse {
  width: 100%;
  height: 200px;
  background-color: #f60;
  text-align: center;
  font-size: 2em;
}
document.querySelector("#mouse").addEventListener("mousemove", (event) => {
  event.target.textContent =
    `position: ${event.offsetX}x, ${event.offsetY}y`;
});

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.