🔸.offsetParent

🔰 JSbrowserDOMtypesHTMLElementborder box ⟩ .offsetParent

the nearest ancestor that the browser uses for calculating coordinates during rendering, one of the following:

  • CSS-positioned (position: absolute/relative/fixed/sticky)

  • <td>, <th>, or <table>

  • <body>

⭐️ Note: .offsetParent returns null in the following situations:

  • it (or its parent) is not shown ( display:none or not in the DOM)

  • it has position:fixed ( Firefox returns <body>).

  • it is <html> or <body>.

Last updated