Measure Rara’s box in a real page on the teacher’s board: whose numbers change when the page scrolls or the box turns, pixel fractions, the width reported…
Tooltips, dropdowns, popovers and highlights beside an element need its place on screen, and that is getBoundingClientRect()’s job: libraries like Floating UI are built on it. Mistaking the rect for document coordinates makes a popover miss as soon as the page scrolls.
The rect is viewport-relative, and measures what is drawn
rect.top as is for position: absolute in the document The rect is viewport-relative. For document coordinates, add the scroll: rect.top + window.scrollY, rect.left + window.scrollX. Without it, the position misses by as far as the page is scrolled.getBoundingClientRect() in a loop or a scroll handler Reading it is cheap while nothing changed since the last frame, and scroll fires at most once a frame. What is costly is changing a style then reading again, in turns, in one loop: every read forces the browser to work out the layout right then. Read everything first, then change; for animation, use requestAnimationFrame.rect.width is the CSS width The rect measures the border box as drawn: with padding and border (unless box-sizing: border-box), and multiplied by transform: scale(). It can differ from your CSS number.rect.top on the board (Rara’s number) changes, offsetTop (Bagas’s) stays.transform: rotate(20deg) The rect (the dashed line) grows bigger than the box, offsetWidth stays 98.margin-left: 20.5px rect.left keeps its fraction, offsetLeft is rounded.box-sizing: border-box rect.width becomes 80, the same as the CSS width.