document.elementsFromPoint() is an instance method that returns an array of all elements at viewport coordinates (see MDN Document: elementsFromPoint()). Learn top-to-bottom ordering, how it relates to elementFromPoint(), reading stacks under the mouse, overlapping layers, and five try-it labs.
01
Kind
Instance method
02
Args
x, y (viewport)
03
Returns
Element[]
04
Order
Top → bottom
05
Like
elementFromPoint
06
Status
Baseline
Fundamentals
Introduction
elementFromPoint() answers “what is on top?” elementsFromPoint() answers “what is the whole stack under this point?” — useful for overlays, stacking contexts, and debugging layers.
MDN: the method returns an array of all elements at the specified coordinates (viewport-relative), ordered from the topmost to the bottommost box. It operates in a similar way to elementFromPoint().
💡
Full hit stack
1) Pick viewport x, y 2) const stack = document.elementsFromPoint(x, y) 3) stack[0] is the topmost element; later indexes are underneath
Document.elementsFromPoint() is Baseline Widely available on MDN (since January 2020). Logos use the shared browser-image-sprite.png sprite from this project.
✓ Baseline Widely available
Document.elementsFromPoint()
Return every Element stacked at viewport coordinates across modern browsers.
BaselineWidely available
Google ChromeSupported
Yes
Mozilla FirefoxSupported
Yes
Apple SafariSupported
Yes
Microsoft EdgeSupported
Yes
OperaSupported
Yes
Internet ExplorerNot supported
No
elementsFromPoint()Wide
Bottom line: Use elementsFromPoint(x, y) when you need the full top-to-bottom hit stack. Prefer elementFromPoint when only the topmost Element matters.
Wrap Up
Conclusion
document.elementsFromPoint(x, y) returns every element under a viewport point, ordered topmost to bottommost. Use it for overlays and layer tools; reach for elementFromPoint when you only need the top hit — just like MDN describes the relationship between the two APIs.
Feature-detect in mixed / older environments (MDN pattern)
Prefer this API when overlays matter
Map localName / id for readable debug output
❌ Don’t
Confuse page coordinates with viewport coordinates
Assume the array never includes html / body
Use this when a single top element is enough
Expect text caret offsets (use caret APIs)
Forget IE lacks support (prefer modern Baseline browsers)
Summary
Key Takeaways
Knowledge Unlocked
Five things to remember about elementsFromPoint()
Full top-to-bottom Element stack at a viewport point.
5
Core concepts
📝01
Returns
Element[]
MDN
📄02
Order
top→bottom
MDN
🎯03
Like
elementFromPoint
stack
🔎04
Index 0
topmost
usual
🛡05
Status
Baseline
2020
❓ Frequently Asked Questions
MDN: Document.elementsFromPoint() returns an array of all elements at the specified coordinates (relative to the viewport), ordered from the topmost to the bottommost box.
No. MDN marks Document.elementsFromPoint() as Baseline Widely available (since January 2020). It is not Deprecated, Experimental, or Non-standard.
MDN: it operates similarly to elementFromPoint(), but returns every element in the stack instead of only the topmost Element.
MDN: ordered from the topmost to the bottommost box of the viewport. Index 0 is usually the same element elementFromPoint() would return.
Yes. Like elementFromPoint, use viewport coordinates such as mouse event clientX and clientY.
MDN’s example checks if (document.elementsFromPoint) before calling. Modern Baseline browsers support it; a check still helps older environments.
Did you know?
MDN’s demo prints the stack with a < separator so it reads like “child under parent under parent” — a handy mental model when the array includes both overlapping siblings and ancestor containers such as body and html.