Learn how to get X and Y positions of HTML elements in JavaScript using getBoundingClientRect() and offset properties. Complete guide with practical examples for viewport and document coordinates.