MDN self-hosted library · e01.org

DOMRectList: length property

Runnable notebook: every JavaScript, HTML and CSS example on this page executes in a sandboxed local frame. Nothing leaves the browser.

html
<div id="box"></div>
<div id="output"></div>
css
#box {
  width: 50px;
  height: 20px;
  border: 1px solid black;
}
js
const box = document.getElementById("box");
const rects = box.getClientRects();
const output = document.getElementById("output");

output.textContent = `Number of rectangles: ${rects.length}`;